[10672] | 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.include-paths}". |
---|
| 21 | #------------------------------------------------------------------------------- |
---|
| 22 | . $(dirname $0)/test_header |
---|
| 23 | |
---|
| 24 | function get_compiler_log() { |
---|
| 25 | sed '/^\[info\] shell(0.*) gfortran/!d; |
---|
| 26 | /hello\.exe/d; |
---|
| 27 | s/^\[info\] shell(0.*) //' .fcm-make/log |
---|
| 28 | } |
---|
| 29 | #------------------------------------------------------------------------------- |
---|
| 30 | tests 11 |
---|
| 31 | cp -r $TEST_SOURCE_DIR/$TEST_KEY_BASE/* . |
---|
| 32 | #------------------------------------------------------------------------------- |
---|
| 33 | TEST_KEY="$TEST_KEY_BASE-control" |
---|
| 34 | run_fail "$TEST_KEY" fcm make |
---|
| 35 | #------------------------------------------------------------------------------- |
---|
| 36 | TEST_KEY="$TEST_KEY_BASE" |
---|
| 37 | FCM_TEST_FC_INCLUDE_PATHS="$PWD/include/world1 $PWD/include/world2" \ |
---|
| 38 | run_pass "$TEST_KEY" fcm make |
---|
| 39 | $PWD/build/bin/hello.exe >"$TEST_KEY.command.out" |
---|
| 40 | file_cmp "$TEST_KEY.command.out" "$TEST_KEY.command.out" <<<'Hello Earth' |
---|
| 41 | get_compiler_log >"$TEST_KEY.gfortran.log" |
---|
| 42 | file_cmp "$TEST_KEY.gfortran.log" "$TEST_KEY.gfortran.log" <<__LOG__ |
---|
| 43 | gfortran -oo/world.o -c -I./include -I$PWD/include/world1 -I$PWD/include/world2 $PWD/src/world.f90 |
---|
| 44 | gfortran -oo/hello.o -c -I./include -I$PWD/include/world1 -I$PWD/include/world2 $PWD/src/hello.f90 |
---|
| 45 | __LOG__ |
---|
| 46 | #------------------------------------------------------------------------------- |
---|
| 47 | TEST_KEY="$TEST_KEY_BASE-incr0" |
---|
| 48 | find build -type f -exec stat -c'%Y %n' {} \; | sort >"$TEST_KEY.mtime.old" |
---|
| 49 | FCM_TEST_FC_INCLUDE_PATHS="$PWD/include/world1 $PWD/include/world2" \ |
---|
| 50 | run_pass "$TEST_KEY" fcm make |
---|
| 51 | find build -type f -exec stat -c'%Y %n' {} \; | sort >"$TEST_KEY.mtime" |
---|
| 52 | file_cmp "$TEST_KEY.mtime" "$TEST_KEY.mtime.old" "$TEST_KEY.mtime" |
---|
| 53 | $PWD/build/bin/hello.exe >"$TEST_KEY.command.out" |
---|
| 54 | file_cmp "$TEST_KEY.command.out" "$TEST_KEY.command.out" <<<'Hello Earth' |
---|
| 55 | get_compiler_log >"$TEST_KEY.gfortran.log" |
---|
| 56 | file_cmp "$TEST_KEY.gfortran.log" "$TEST_KEY.gfortran.log" </dev/null |
---|
| 57 | #------------------------------------------------------------------------------- |
---|
| 58 | TEST_KEY="$TEST_KEY_BASE-incr1" |
---|
| 59 | FCM_TEST_FC_INCLUDE_PATHS="$PWD/include/world2 $PWD/include/world1" \ |
---|
| 60 | run_pass "$TEST_KEY" fcm make |
---|
| 61 | $PWD/build/bin/hello.exe >"$TEST_KEY.command.out" |
---|
| 62 | file_cmp "$TEST_KEY.command.out" "$TEST_KEY.command.out" <<<'Hello Moon' |
---|
| 63 | get_compiler_log >"$TEST_KEY.gfortran.log" |
---|
| 64 | file_cmp "$TEST_KEY.gfortran.log" "$TEST_KEY.gfortran.log" <<__LOG__ |
---|
| 65 | gfortran -oo/world.o -c -I./include -I$PWD/include/world2 -I$PWD/include/world1 $PWD/src/world.f90 |
---|
| 66 | gfortran -oo/hello.o -c -I./include -I$PWD/include/world2 -I$PWD/include/world1 $PWD/src/hello.f90 |
---|
| 67 | __LOG__ |
---|
| 68 | #------------------------------------------------------------------------------- |
---|
| 69 | exit 0 |
---|