Skip to content

Commit

Permalink
macro_attr
Browse files Browse the repository at this point in the history
  • Loading branch information
sim-immunant committed Oct 7, 2023
1 parent 532e02d commit f27b74a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions rewriter/tests/macro_attr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ define_shared_lib(
define_test(
SRCS main.c
NEEDS_LD_WRAP
CRITERION_TEST
)

# Build the wrapper lib
Expand Down
14 changes: 7 additions & 7 deletions rewriter/tests/macro_attr/functions.c
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
/*
RUN: cat macro_attr_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include <stdio.h>
#include <criterion/logging.h>
#include "functions.h"

// LINKARGS: --wrap=f
void f() {
printf("Called `f()`\n");
cr_log_info("Called `f()`");
}

// LINKARGS: --wrap=g
void g() {
printf("Called `g()`\n");
cr_log_info("Called `g()`");
}

// TODO(src_rewriter_wip): this gets --wrap, but i don't think it should
void h(CB cb) {
printf("Calling `cb(0)` from `h`\n");
cr_log_info("Calling `cb(0)` from `h`");
cb(0);
}

// LINKARGS: --wrap=i
void i() {
printf("Called `i()`\n");
cr_log_info("Called `i()`");
}

// LINKARGS: --wrap=j
void j() {
printf("Called `j()`\n");
cr_log_info("Called `j()`");
}

// LINKARGS: --wrap=k
void k() {
printf("Called `k()`\n");
cr_log_info("Called `k()`");
}
3 changes: 2 additions & 1 deletion rewriter/tests/macro_attr/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ RUN: sh -c 'if [ ! -s "macro_attr_call_gates_0.ld" ]; then echo "No link args as
*/
#include "functions.h"
#include <ia2.h>
#include <criterion/criterion.h>

INIT_RUNTIME(1);
#define IA2_COMPARTMENT 1
#include <ia2_compartment_init.inc>

int main() {
Test(macro_attr, main) {
f();
g();
i();
Expand Down

0 comments on commit f27b74a

Please sign in to comment.