Skip to content

Commit

Permalink
Convert recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
sim-immunant committed Sep 27, 2023
1 parent 114bb30 commit 230d272
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions rewriter/tests/recursion/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ define_test(
PKEY 1
NEEDS_LD_WRAP
INCLUDE_DIR include/dso
CRITERION_TEST
)

define_ia2_wrapper()
9 changes: 5 additions & 4 deletions rewriter/tests/recursion/dso.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
RUN: cat recursion_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include "recursion_main.h"
#include <criterion/criterion.h>
#include <ia2.h>
#include <stdio.h>

Expand All @@ -10,8 +11,8 @@ RUN: cat recursion_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s

// LINKARGS: --wrap=recurse_dso
void recurse_dso(int count) {
printf("recursion_dso: %d\n", count);
if (count > 0) {
recurse_main(count - 1);
}
cr_log_info("recursion_dso: %d\n", count);
if (count > 0) {
recurse_main(count - 1);
}
}
20 changes: 9 additions & 11 deletions rewriter/tests/recursion/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/*
RUN: cat recursion_call_gates_2.ld | FileCheck --check-prefix=LINKARGS %s
RUN: %binary_dir/tests/recursion/recursion_main_wrapped | diff %S/Output/recursion.out -
*/

#include "recursion_dso.h"
#include <criterion/criterion.h>
#include <criterion/logging.h>
#include <ia2.h>
#include <stdio.h>
#include "recursion_dso.h"
#define IA2_DEFINE_TEST_HANDLER
#include "test_fault_handler.h"

Expand All @@ -15,15 +16,12 @@ INIT_RUNTIME(2);

// LINKARGS: --wrap=recurse_main
void recurse_main(int count) {
printf("recursion_main: %d\n", count);
if (count > 0) {
recurse_dso(count - 1);
}
cr_log_info("recursion_main: %d\n", count);
if (count > 0) {
recurse_dso(count - 1);
}
}

int main() {
recurse_main(5);

// We fault in a destructor while exiting, TODO: #112
expect_fault = true;
Test(recursion, main) {
recurse_main(5);
}

0 comments on commit 230d272

Please sign in to comment.