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

Make lit optional #306

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
31 changes: 29 additions & 2 deletions rewriter/tests/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lit
from lit.llvm import llvm_config
from lit.llvm.subst import ToolSubst
import os

# name: The name of this test suite.
config.name = 'IA2'
Expand All @@ -18,8 +19,34 @@
# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
# subdirectories contain auxiliary inputs for various tests in their parent
# directories.
config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt',
'libusb', 'ffmpeg', 'destructors']
#config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt',
# 'libusb', 'ffmpeg', 'destructors']
config.excludes = [entry.name for entry in os.scandir(os.path.dirname(os.path.abspath(__file__))) if entry.name not in [
'global_fn_ptr',
'header_includes',
'heap_two_keys',
'macro_attr',
'minimal',
'mmap_loop',
'omit_wrappers',
'protected_threads',
'read_config',
'recursion',
'rewrite_fn_ptr_eq',
'rewrite_macros',
'ro_sharing',
'shared_data',
'should_segfault',
'sighandler',
'simple1',
'structs',
'threads',
'trusted_direct',
'trusted_indirect',
'two_keys_minimal',
'two_shared_ranges',
'untrusted_indirect',
]]

# test_source_root: The root path where tests are located.
config.test_source_root = os.path.dirname(__file__)
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/minimal/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/*
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
5 changes: 0 additions & 5 deletions rewriter/tests/permissive_mode/permissive_mode.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
RUN: true
*/
// TODO remove the above when lit is removed. As of now a RUN line is required.

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/read_config/main.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
RUN: cat read_config_call_gates_2.ld | FileCheck --check-prefix=LINKARGS %s
RUN: readelf -lW %binary_dir/tests/read_config/read_config_main_wrapped | FileCheck --check-prefix=SEGMENTS %s
RUN: cat main.c | FileCheck --match-full-lines --check-prefix=REWRITER %s
*/

// Check that readelf shows exactly one executable segment
// SEGMENTS-COUNT-1: LOAD{{.*}}R E
// SEGMENTS-NOT: LOAD{{.*}}R E
#include "plugin.h"
#include <criterion/criterion.h>
#include <criterion/logging.h>
Expand Down
5 changes: 2 additions & 3 deletions rewriter/tests/read_config/plugin.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*
RUN: readelf -lW %binary_dir/tests/read_config/libread_config_lib_wrapped.so | FileCheck --check-prefix=SEGMENTS %s
RUN: true
We need this because main.c uses LINKARGS checks but not this file.
*/

// Check that readelf shows exactly one executable segment
// SEGMENTS-COUNT-1: LOAD{{.*}}R E
// SEGMENTS-NOT: LOAD{{.*}}R E
#include "plugin.h"
#include "core.h"
#include <ia2.h>
Expand Down
2 changes: 2 additions & 0 deletions rewriter/tests/sighandler/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*
RUN: true
We need this because lib.c uses LINKARGS checks but not this file.
*/

#include "lib.h"
#include <stddef.h>
#include <signal.h>
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/tls_protected/library.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
/*
RUN: readelf -lW %binary_dir/tests/tls_protected/libtls_protected_lib_wrapped.so | 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 "library.h"
#include "test_fault_handler.h"
#include <criterion/criterion.h>
Expand Down
4 changes: 0 additions & 4 deletions rewriter/tests/tls_protected/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
RUN: true
*/

#include <criterion/criterion.h>
#include <criterion/logging.h>
#include <ia2.h>
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/two_keys_minimal/main.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
RUN: sh -c 'if [ ! -s "should_segfault_call_gates_0.ld" ]; then echo "No link args as expected"; exit 0; fi; echo "Unexpected link args"; exit 1;'
RUN: cat two_keys_minimal_call_gates_2.ld | FileCheck --check-prefix=LINKARGS %s
RUN: readelf -lW %binary_dir/tests/two_keys_minimal/two_keys_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 <criterion/logging.h>
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/two_keys_minimal/plugin.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/*
RUN: cat two_keys_minimal_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
RUN: readelf -lW %binary_dir/tests/two_keys_minimal/libtwo_keys_minimal_lib_wrapped.so | 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 <criterion/logging.h>
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/two_shared_ranges/main.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/*
RUN: cat two_shared_ranges_call_gates_2.ld | FileCheck --check-prefix=LINKARGS %s
RUN: readelf -lW %binary_dir/tests/two_shared_ranges/two_shared_ranges_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 <criterion/logging.h>
Expand Down
3 changes: 0 additions & 3 deletions rewriter/tests/two_shared_ranges/plugin.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
/*
RUN: cat two_shared_ranges_call_gates_1.ld | FileCheck --check-prefix=LINKARGS %s
RUN: readelf -lW %binary_dir/tests/two_shared_ranges/libtwo_shared_ranges_lib_wrapped.so | 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/logging.h>
#include <ia2.h>
Expand Down