Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lit #305

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion rewriter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ message(STATUS "Found LLVM: ${LLVM_DIR} (found version \"${LLVM_PACKAGE_VERSION}
find_package(Clang REQUIRED CONFIG)
message(STATUS "Found Clang: ${Clang_DIR}")

# We use the lit CMake functions from LLVM
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check-ia2 works without these lines but nginx build seems to need these

list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)

Expand Down
14 changes: 1 addition & 13 deletions rewriter/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,9 @@ include("../../cmake/define-ia2-wrapper.cmake")
include("../../cmake/define-test.cmake")
include("../../cmake/add-tls-padded-library.cmake")

configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)

set(IA2_TEST_DEPENDS ia2-rewriter)

add_lit_testsuite(check-ia2 "Running the IA2 tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${IA2_TEST_DEPENDS} partition-alloc
ARGS "--verbose"
)
set_target_properties(check-ia2 PROPERTIES FOLDER "tests")
add_custom_target(check-ia2)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down
14 changes: 0 additions & 14 deletions rewriter/tests/ffmpeg/ffmpeg.test
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
# libavformat
RUN: sh -c "for hdr in avformat.h avio.h; do %ia2_generate_checks $(pkg-config --variable includedir libavformat)/libavformat/$hdr %S/include %T/$hdr; done"
RUN: ia2-rewriter --output-header %T/fn_ptr_ia2_avformat.h %T/wrapper.c %T/avformat.h %T/avio.h -- -I%resource_dir -I%ia2_include

RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/avformat.h
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/avio.h

# libavutil
RUN: sh -c "for hdr in dict.h version.h macros.h common.h attributes.h mem.h avutil.h rational.h mathematics.h intfloat.h error.h log.h pixfmt.h; do %ia2_generate_checks $(pkg-config --variable includedir libavutil)/libavutil/$hdr %S/include %T/$hdr; done"
RUN: ia2-rewriter --output-header %T/fn_ptr_ia2_avutil.h %T/wrapper.c %T/dict.h %T/version.h %T/macros.h %T/common.h %T/attributes.h %T/mem.h %T/avutil.h %T/rational.h %T/mathematics.h %T/intfloat.h %T/error.h %T/log.h %T/pixfmt.h -- -I%resource_dir -I%ia2_include

RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/dict.h
# version.h has only #defines, so it doesn't have anything we would CHECK
# macros.h has only #defines, so it doesn't have anything we would CHECK
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/common.h
# attributes.h has only #defines, so it doesn't have anything we would CHECK
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/mem.h
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/avutil.h
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/rational.h
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/mathematics.h
# intfloat.h has only #defines and "static inline" functions, so it doesn't have anything we would CHECK for now
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/error.h
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/log.h
# pixfmt.h has only #defines and enums, so it doesn't have anything we would CHECK
2 changes: 0 additions & 2 deletions rewriter/tests/ffmpeg/lit.local.cfg.py

This file was deleted.

2 changes: 0 additions & 2 deletions rewriter/tests/global_fn_ptr/Output/operations.out

This file was deleted.

4 changes: 0 additions & 4 deletions rewriter/tests/global_fn_ptr/include/operations.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/*
RUN: cat %t.c.args | FileCheck --check-prefix=LINKARGS %s
*/

#pragma once
#include <stdlib.h>
#include <stdint.h>

// LINKARGS: --wrap=call_operations
uint32_t call_operation(size_t i);

// CHECK: typedef struct IA2_fnptr__ZTSPFjjjE WordFn;
Expand Down
7 changes: 0 additions & 7 deletions rewriter/tests/global_fn_ptr/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
RUN: sh -c 'if [ ! -s "global_fn_ptr_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;'
*/
#include "operations.h"
#include <ia2.h>
#include <criterion/criterion.h>
Expand All @@ -15,24 +12,20 @@ INIT_RUNTIME(1);

// `sum` can't be set to __ia2_add since it's defined in asm so the compiler doesn't know it's a valid initializer
//static WordFn sum = __ia2_add;
// REWRITER: static WordFn sum = IA2_FN(add);
static WordFn sum = add;
// REWRITER: static HalfFn diff = IA2_FN(sub);
static HalfFn diff = sub;
// The following won't compile since the inner pointer is also type-specific
//static HalfFn mul = {&__ia2_mul_0_1};

Op operations[2] IA2_SHARED_DATA = {
{
{ "add", 4 },
// REWRITER: IA2_FN(add),
add,
{ "Adds two u32s", 14 },
0,
},
{
{ "mul", 4 },
// REWRITER: IA2_FN(mul),
mul,
{ "Multiply two u32s", 18 },
0,
Expand Down
4 changes: 0 additions & 4 deletions rewriter/tests/global_fn_ptr/operations.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
/*
RUN: cat global_fn_ptr_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include "operations.h"
#include <criterion/criterion.h>
#include <stdio.h>

extern Op operations[2];

// LINKARGS: --wrap=call_operation
uint32_t call_operation(size_t i) {
// TODO: Add a way to share strings between compartments
//printf("%s\n", operations[i].desc.data);
Expand Down
4 changes: 0 additions & 4 deletions rewriter/tests/header_includes/impl.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/*
RUN: cat header_includes_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include "types.h"

// LINKARGS: --wrap=unwrap_or
int unwrap_or(Option opt, int default_value) {
if (opt.present) {
return opt.value;
Expand Down
1 change: 0 additions & 1 deletion rewriter/tests/header_includes/include/impl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma once
#include "types.h"

// LINKARGS: --wrap=unwrap_or
int unwrap_or(Option opt, int default_value);
5 changes: 0 additions & 5 deletions rewriter/tests/header_includes/liboption.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/*
RUN: cat header_includes_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include <criterion/logging.h>
#include "liboption.h"
#include "types.h"

// LINKARGS: --wrap=None
Option None() {
cr_log_info("returning `None`");
Option none = {
Expand All @@ -15,7 +11,6 @@ Option None() {
return none;
}

// LINKARGS: --wrap=Some
Option Some(int x) {
cr_log_info("returning `Some(%d)`", x);
Option opt = {
Expand Down
2 changes: 0 additions & 2 deletions rewriter/tests/header_includes/lit.local.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions rewriter/tests/header_includes/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
RUN: sh -c 'if [ ! -s "header_includes_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;'
*/
#include "liboption.h"
#include "types.h"
#include <criterion/criterion.h>
Expand Down
Empty file.
1 change: 0 additions & 1 deletion rewriter/tests/heap_two_keys/Output/fault.out

This file was deleted.

3 changes: 0 additions & 3 deletions rewriter/tests/heap_two_keys/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
RUN: sh -c 'if [ ! -s "heap_two_keys_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;'
*/
#include <criterion/criterion.h>
#include <criterion/logging.h>
#include <criterion/new/assert.h>
Expand Down
8 changes: 0 additions & 8 deletions rewriter/tests/heap_two_keys/plugin.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
RUN: cat heap_two_keys_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include <stdio.h>
#include <ia2.h>
#include "exported_fn.h"
Expand All @@ -9,7 +6,6 @@ RUN: cat heap_two_keys_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
#define IA2_COMPARTMENT 2
#include <ia2_compartment_init.inc>

// LINKARGS: --wrap=read_from_plugin
uint8_t read_from_plugin(uint8_t *ptr) {
if (ptr == NULL) {
return -1;
Expand All @@ -18,7 +14,6 @@ uint8_t read_from_plugin(uint8_t *ptr) {
return read;
}

// LINKARGS: --wrap=read_from_plugin_expect_fault
uint8_t read_from_plugin_expect_fault(uint8_t *ptr) {
if (ptr == NULL) {
return -1;
Expand All @@ -27,18 +22,15 @@ uint8_t read_from_plugin_expect_fault(uint8_t *ptr) {
return read;
}

// LINKARGS: --wrap=trigger_compartment_init
void trigger_compartment_init(void) {}

// LINKARGS: --wrap=write_from_plugin
void write_from_plugin(uint8_t *ptr, uint8_t value) {
if (ptr == NULL) {
return;
}
*ptr = value;
}

// LINKARGS: --wrap=write_from_plugin_expect_fault
void write_from_plugin_expect_fault(uint8_t *ptr, uint8_t value) {
if (ptr == NULL) {
return;
Expand Down
4 changes: 0 additions & 4 deletions rewriter/tests/libusb/libusb.test
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
RUN: sh -c "%ia2_generate_checks $(pkg-config --variable includedir libusb-1.0)/libusb-1.0/libusb.h %S/include %T/libusb.h"
RUN: ia2-rewriter --output-header %T/fn_ptr_ia2.h %T/wrapper.c %T/libusb.h -- -I%resource_dir -I%ia2_include
RUN: cat %T/wrapper.c.args | FileCheck --check-prefix=LINKARGS %T/libusb.h
RUN: cat %T/libusb.h | sed 's/^.*CHECK.*$//' | FileCheck --check-prefix 'TYPEDEF-CHECK' %T/libusb.h
2 changes: 0 additions & 2 deletions rewriter/tests/libusb/lit.local.cfg.py

This file was deleted.

39 changes: 0 additions & 39 deletions rewriter/tests/lit.cfg.py

This file was deleted.

41 changes: 0 additions & 41 deletions rewriter/tests/lit.site.cfg.py.in

This file was deleted.

8 changes: 0 additions & 8 deletions rewriter/tests/macro_attr/functions.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
/*
RUN: cat macro_attr_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/
#include <criterion/logging.h>
#include "functions.h"

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

// LINKARGS: --wrap=g
void g() {
cr_log_info("Called `g()`");
}
Expand All @@ -20,17 +15,14 @@ void h(CB cb) {
cb(0);
}

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

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

// LINKARGS: --wrap=k
void k() {
cr_log_info("Called `k()`");
}
3 changes: 0 additions & 3 deletions rewriter/tests/macro_attr/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
RUN: sh -c 'if [ ! -s "macro_attr_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;'
*/
#include "functions.h"
#include <ia2.h>
#include <criterion/criterion.h>
Expand Down
1 change: 0 additions & 1 deletion rewriter/tests/minimal/Output/minimal.out

This file was deleted.

6 changes: 0 additions & 6 deletions rewriter/tests/minimal/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/*
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;'
RUN: readelf -lW %binary_dir/tests/minimal/minimal_main_wrapped | FileCheck --check-prefix=SEGMENTS %s
*/

// Check that readelf shows exactly one executable segment
// SEGMENTS-COUNT-1: LOAD{{.*}}R E
// SEGMENTS-NOT: LOAD{{.*}}R E

#include <criterion/criterion.h>
#include "minimal.h"
Expand Down
6 changes: 0 additions & 6 deletions rewriter/tests/minimal/minimal.c
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
/*
RUN: cat minimal_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
*/

#include "minimal.h"
#include <criterion/logging.h>

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

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

// LINKARGS: --wrap=return_val
int return_val() {
cr_log_info("return_val");
return 1;
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/mmap_loop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
set(STDOUT_REF ${CMAKE_CURRENT_SOURCE_DIR}/Output/mmap_loop.out)
configure_file(${STDOUT_REF} ${CMAKE_CURRENT_BINARY_DIR}/mmap_loop.out)

define_shared_lib(
SRCS mmap_loop.c
PKEY 2
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/mmap_loop/Output/mmap_loop.out

This file was deleted.

Loading