1 | #!/bin/bash |
---|
2 | #------------------------------------------------------------------------------- |
---|
3 | # (C) British Crown Copyright 2006-17 Met Office. |
---|
4 | # |
---|
5 | # This file is part of FCM, tools for managing and building source code. |
---|
6 | # |
---|
7 | # FCM is free software: you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation, either version 3 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # FCM is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with FCM. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | #------------------------------------------------------------------------------- |
---|
20 | # Tests for "fcm make", "build.prop{fc.lib-paths}" and "build.prop{fc.libs}". |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . $(dirname $0)/test_header |
---|
23 | |
---|
24 | function get_linker_log() { |
---|
25 | sed '/^\[info\] shell(0.*) gfortran/!d; |
---|
26 | s/^\[info\] shell(0.*) //' .fcm-make/log |
---|
27 | } |
---|
28 | #------------------------------------------------------------------------------- |
---|
29 | tests 11 |
---|
30 | set -e |
---|
31 | cp -r $TEST_SOURCE_DIR/$TEST_KEY_BASE/* . |
---|
32 | gfortran -c src-lib/* |
---|
33 | mkdir -p greet/lib |
---|
34 | ar rs greet/lib/libgreet.a greet.o 2>/dev/null |
---|
35 | ar rs greet/lib/libearth.a earth.o 2>/dev/null |
---|
36 | ar rs greet/lib/libmoon.a moon.o 2>/dev/null |
---|
37 | rm *.o |
---|
38 | set +e |
---|
39 | #------------------------------------------------------------------------------- |
---|
40 | TEST_KEY="$TEST_KEY_BASE-control" |
---|
41 | run_fail "$TEST_KEY" fcm make |
---|
42 | #------------------------------------------------------------------------------- |
---|
43 | TEST_KEY="$TEST_KEY_BASE" |
---|
44 | FCM_TEST_FC_LIBS='greet earth' run_pass "$TEST_KEY" fcm make |
---|
45 | $PWD/build/bin/hello.exe >"$TEST_KEY.command.out" |
---|
46 | file_cmp "$TEST_KEY.command.out" "$TEST_KEY.command.out" <<<'Hello Earth' |
---|
47 | get_linker_log >"$TEST_KEY.gfortran.log" |
---|
48 | file_cmp "$TEST_KEY.gfortran.log" "$TEST_KEY.gfortran.log" <<__LOG__ |
---|
49 | gfortran -obin/hello.exe o/hello.o -L$PWD/greet/lib -lgreet -learth |
---|
50 | __LOG__ |
---|
51 | #------------------------------------------------------------------------------- |
---|
52 | TEST_KEY="$TEST_KEY_BASE-incr0" |
---|
53 | find build -type f -exec stat -c'%Y %n' {} \; | sort >"$TEST_KEY.mtime.old" |
---|
54 | FCM_TEST_FC_LIBS='greet earth' run_pass "$TEST_KEY" fcm make |
---|
55 | find build -type f -exec stat -c'%Y %n' {} \; | sort >"$TEST_KEY.mtime" |
---|
56 | file_cmp "$TEST_KEY.mtime" "$TEST_KEY.mtime.old" "$TEST_KEY.mtime" |
---|
57 | $PWD/build/bin/hello.exe >"$TEST_KEY.command.out" |
---|
58 | file_cmp "$TEST_KEY.command.out" "$TEST_KEY.command.out" <<<'Hello Earth' |
---|
59 | get_linker_log >"$TEST_KEY.gfortran.log" |
---|
60 | file_cmp "$TEST_KEY.gfortran.log" "$TEST_KEY.gfortran.log" </dev/null |
---|
61 | #------------------------------------------------------------------------------- |
---|
62 | TEST_KEY="$TEST_KEY_BASE-incr1" |
---|
63 | FCM_TEST_FC_LIBS='greet moon' run_pass "$TEST_KEY" fcm make |
---|
64 | $PWD/build/bin/hello.exe >"$TEST_KEY.command.out" |
---|
65 | file_cmp "$TEST_KEY.command.out" "$TEST_KEY.command.out" <<<'Hello Moon' |
---|
66 | get_linker_log >"$TEST_KEY.gfortran.log" |
---|
67 | file_cmp "$TEST_KEY.gfortran.log" "$TEST_KEY.gfortran.log" <<__LOG__ |
---|
68 | gfortran -obin/hello.exe o/hello.o -L$PWD/greet/lib -lgreet -lmoon |
---|
69 | __LOG__ |
---|
70 | #------------------------------------------------------------------------------- |
---|
71 | exit 0 |
---|