Skip to content

Commit 48629e2

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 1e186ee commit 48629e2

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

regression/goto-gcc/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,16 @@
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
10+
"$<TARGET_FILE_DIR:goto-cc>/goto-gcc"
11+
"${CMAKE_CURRENT_SOURCE_DIR}/archives/foo.c"
12+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/archives"
13+
)
14+
15+
add_custom_target(libour_archive.a ALL
16+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/archives/libour_archive.a"
17+
)

regression/goto-gcc/Makefile

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,20 @@ test:
99
tests.log: ../test.pl
1010

1111
else
12-
test:
13-
-@ln -s goto-cc ../../src/goto-cc/goto-gcc
12+
test: ../../src/goto-cc/goto-gcc
1413
@../test.pl -p -c ../../../src/goto-cc/goto-gcc
1514

16-
tests.log: ../test.pl
17-
-@ln -s goto-cc ../../src/goto-cc/goto-gcc
15+
tests.log: ../test.pl ../../src/goto-cc/goto-gcc
1816
@../test.pl -p -c ../../../src/goto-cc/goto-gcc
1917

18+
../../src/goto-cc/goto-gcc: ../../src/goto-cc/goto-cc
19+
@ln -sf goto-cc ../../src/goto-cc/goto-gcc
20+
21+
test tests.log: archives/libour_archive.a
22+
archives/libour_archive.a: archives/foo.c ../../src/goto-cc/goto-gcc
23+
@cd archives && \
24+
../../../src/goto-cc/goto-gcc -c foo.c && \
25+
$(AR) rcs libour_archive.a foo.o
2026
endif
2127

2228
show:
@@ -30,4 +36,4 @@ clean:
3036
find -name '*.out' -execdir $(RM) '{}' \;
3137
find -name '*.gb' -execdir $(RM) '{}' \;
3238
find -name '*.goto-cc-saved' -execdir $(RM) '{}' \;
33-
$(RM) tests.log
39+
$(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)