1 | #!/bin/bash |
---|
2 | #------------------------------------------------------------------------------- |
---|
3 | # Copyright (C) 2006-2021 British Crown (Met Office) & Contributors. |
---|
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 | # Test "fcm make", build, using SHA1 checksum to determine changes. |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | . "$(dirname "$0")/test_header" |
---|
23 | |
---|
24 | get-hello-checksum() { |
---|
25 | PERL5LIB="${FCM_HOME}/lib" perl - <<'__PERL__' |
---|
26 | use strict; |
---|
27 | use warnings; |
---|
28 | use IO::Uncompress::Gunzip qw{gunzip}; |
---|
29 | use Storable; |
---|
30 | gunzip('.fcm-make/ctx.gz', 'ctx'); |
---|
31 | my $m_ctx = retrieve('ctx'); |
---|
32 | printf( |
---|
33 | "%s %s\n", |
---|
34 | $m_ctx->{'ctx_of'}{'build'}{'source_of'}{'hello.f90'}{'checksum'}, |
---|
35 | 'src/hello.f90', |
---|
36 | ); |
---|
37 | unlink('ctx') |
---|
38 | __PERL__ |
---|
39 | } |
---|
40 | #------------------------------------------------------------------------------- |
---|
41 | tests 8 |
---|
42 | cp -r "${TEST_SOURCE_DIR}/${TEST_KEY_BASE}/"* . |
---|
43 | #------------------------------------------------------------------------------- |
---|
44 | TEST_KEY="${TEST_KEY_BASE}" |
---|
45 | run_pass "${TEST_KEY}" fcm make |
---|
46 | run_pass "${TEST_KEY}-sha1sum-check" sha1sum -c - <<<"$(get-hello-checksum)" |
---|
47 | HELLO_O_MTIME="$(stat -c '%Y' 'build/o/hello.o')" |
---|
48 | #------------------------------------------------------------------------------- |
---|
49 | TEST_KEY="${TEST_KEY_BASE}-incr" |
---|
50 | run_pass "${TEST_KEY}" fcm make |
---|
51 | run_pass "${TEST_KEY}-sha1sum-check" sha1sum -c - <<<"$(get-hello-checksum)" |
---|
52 | HELLO_O_MTIME_INCR="$(stat -c '%Y' 'build/o/hello.o')" |
---|
53 | run_pass "${TEST_KEY}-mtime-of-hello.o" \ |
---|
54 | test "${HELLO_O_MTIME_INCR}" -eq "${HELLO_O_MTIME}" |
---|
55 | #------------------------------------------------------------------------------- |
---|
56 | TEST_KEY="${TEST_KEY_BASE}-incr-2" |
---|
57 | sed -i 's/Hello/Greet/' 'src/hello.f90' |
---|
58 | sleep 1 # In case computer is very fast, when everything can happen within 1s. |
---|
59 | run_pass "${TEST_KEY}" fcm make |
---|
60 | run_pass "${TEST_KEY}-sha1sum-check" sha1sum -c - <<<"$(get-hello-checksum)" |
---|
61 | HELLO_O_MTIME_INCR="$(stat -c '%Y' 'build/o/hello.o')" |
---|
62 | run_pass "${TEST_KEY}-mtime-of-hello.o" \ |
---|
63 | test "${HELLO_O_MTIME_INCR}" -gt "${HELLO_O_MTIME}" |
---|
64 | #------------------------------------------------------------------------------- |
---|
65 | exit 0 |
---|