Skip to content

Commit 1e0760a

Browse files
committed
Test loading files from an archive
The test requires building platform-specific code, and thus additional rules were added to the Makefile.
1 parent 0171802 commit 1e0760a

File tree

5 files changed

+47
-5
lines changed

5 files changed

+47
-5
lines changed

regression/goto-gcc/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@
22
# isn't marked as an executable (target), which CMake requires. Thus construct a
33
# path in the same way the symbolic link is created in the goto-cc directory.
44
add_test_pl_tests("$<TARGET_FILE_DIR:goto-cc>/goto-gcc")
5+
6+
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a"
7+
COMMAND "$<TARGET_FILE_DIR:goto-cc>/goto-gcc" -c foo.c
8+
COMMAND ${CMAKE_AR} rcs libour_archive.a foo.o
9+
DEPENDS "$<TARGET_FILE_DIR:goto-cc>/goto-gcc"
10+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/archives"
11+
)
12+
13+
add_custom_target(libour_archive.a ALL
14+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a"
15+
)

regression/goto-gcc/Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
default: tests.log
22

3-
test:
4-
-@ln -s goto-cc ../../src/goto-cc/goto-gcc
3+
test: ../../src/goto-cc/goto-gcc
54
@../test.pl -p -c ../../../src/goto-cc/goto-gcc
65

7-
tests.log: ../test.pl
8-
-@ln -s goto-cc ../../src/goto-cc/goto-gcc
6+
tests.log: ../test.pl ../../src/goto-cc/goto-gcc
97
@../test.pl -p -c ../../../src/goto-cc/goto-gcc
108

9+
../../src/goto-cc/goto-gcc: ../../src/goto-cc/goto-cc
10+
@ln -sf goto-cc ../../src/goto-cc/goto-gcc
11+
12+
test tests.log: archives/libour_archive.a
13+
archives/libour_archive.a: archives/foo.c ../../src/goto-cc/goto-gcc
14+
@cd archives && \
15+
../../../src/goto-cc/goto-gcc -c foo.c && \
16+
$(AR) rcs libour_archive.a foo.o
17+
1118
show:
1219
@for dir in *; do \
1320
if [ -d "$$dir" ]; then \
@@ -19,4 +26,4 @@ clean:
1926
find -name '*.out' -execdir $(RM) '{}' \;
2027
find -name '*.gb' -execdir $(RM) '{}' \;
2128
find -name '*.goto-cc-saved' -execdir $(RM) '{}' \;
22-
$(RM) tests.log
29+
$(RM) tests.log archives/lib_ourarchive.a archives/foo.o

regression/goto-gcc/archives/foo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int foo()
2+
{
3+
return 0;
4+
}

regression/goto-gcc/archives/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int foo();
2+
3+
int main()
4+
{
5+
return foo();
6+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CORE
2+
10
3+
main.c -L. -lour_archive --verbosity
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^Reading: .*/foo.o$
7+
--
8+
^warning: ignoring
9+
^CONVERSION ERROR$
10+
--
11+
We need to make sure main.c is listed before the archive for the Linux linker to
12+
pick up dependencies - thus "main.c" is given as an argument on line 3 in this
13+
file and the "10" in line 2 is a dummy to be appended at the end, setting the
14+
verbosity as needed.

0 commit comments

Comments
 (0)