Skip to content

Commit

Permalink
WIP Add criterion-free minimal test for ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
ayrtonm committed Feb 23, 2024
1 parent 9c14ecc commit eeeaacc
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions rewriter/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_subdirectory(heap_two_keys)
# add_subdirectory(libusb)
add_subdirectory(macro_attr)
add_subdirectory(minimal)
add_subdirectory(minimal_arm)
add_subdirectory(mmap_loop)
# TODO: support C++ namespaces
#add_subdirectory(namespaces)
Expand Down
11 changes: 11 additions & 0 deletions rewriter/tests/minimal_arm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Build the wrapped lib
define_shared_lib(SRCS minimal.c)

# Build the test
define_test(
SRCS main.c
NEEDS_LD_WRAP
)

# Build the wrapper lib
define_ia2_wrapper()
1 change: 1 addition & 0 deletions rewriter/tests/minimal_arm/Output/minimal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo
10 changes: 10 additions & 0 deletions rewriter/tests/minimal_arm/include/minimal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

// This function does nothing
void foo();

// This returns an integer
int return_val();

// This takes an integer
void arg1(int x);
18 changes: 18 additions & 0 deletions rewriter/tests/minimal_arm/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
RUN: sh -c 'if [ ! -s "minimal_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;'
*/

// Check that readelf shows exactly one executable segment

#include "minimal.h"
#include <ia2.h>
#include <stdio.h>

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

int main() {
printf("Calling foo");
foo();
}
23 changes: 23 additions & 0 deletions rewriter/tests/minimal_arm/minimal.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
RUN: cat minimal_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/

#include "minimal.h"
#include <stdio.h>

// LINKARGS: --wrap=arg1
void arg1(int x) {
printf("arg1");
}

// LINKARGS: --wrap=foo
void foo() {
printf("foo");
}

// LINKARGS: --wrap=return_val
int return_val() {
printf("return_val");
return 1;
}

0 comments on commit eeeaacc

Please sign in to comment.