|
1 |
| -# Setup the root path |
2 |
| -root_path="$1" |
| 1 | +# Setup theforceengine binary directory |
| 2 | +root_path="" |
3 | 3 |
|
4 |
| -# TFE does not like tildes in paths |
5 |
| -user_path=~ |
| 4 | +# If unset try to look in a common folder |
| 5 | +if [[ ! -s "$root_path" || ! -f "$root_path/theforceengine" ]]; then |
| 6 | + root_path="$(dirname "$(realpath "$0")")"/../../ |
| 7 | + if [ -f $root_path/theforceengine ]; then |
| 8 | + echo "Found theforceengine in path $root_path" |
| 9 | + else |
| 10 | + echo "WARNING: Cannot find theforceengine binary. Will try one folder up" |
| 11 | + root_path="$(dirname "$(realpath "$0")")"/../../../ |
| 12 | + if [ -f $root_path/theforceengine ]; then |
| 13 | + echo "Found theforceengine in path $root_path" |
| 14 | + else |
| 15 | + echo "ERROR: Cannot find theforceengine binary. Please set it in the script" |
| 16 | + exit 1 |
| 17 | + fi |
| 18 | + fi |
| 19 | +fi |
6 | 20 |
|
7 |
| -ls -tral $root_path |
| 21 | +# Directory where your TFE logs are kept - needed for logs |
| 22 | +user_doc_path="" |
8 | 23 |
|
9 |
| -ls -tral $root_path/TheForceEngine/ |
| 24 | +if [[ ! -s "$user_doc_path" || ! -d "$user_doc_path" ]]; then |
| 25 | + # TFE does not like tildes in paths |
| 26 | + user_root=$(realpath ~) |
| 27 | + user_doc_path=$user_root/.local/share/TheForceEngine |
| 28 | + if [ -d $user_doc_path ]; then |
| 29 | + echo "Found the user directory in $user_doc_path" |
| 30 | + else |
| 31 | + echo "WARNING: Cannot find the user tfe directory $user_doc_path. Hopefully it will be created by the executable" |
| 32 | + fi |
| 33 | +fi |
10 | 34 |
|
11 |
| -ls -tral $root_path/TheForceEngine/Tests/Replays/ |
| 35 | +# Path to the demo file |
| 36 | +demo_path="" |
12 | 37 |
|
13 |
| -ldd $root_path/TheForceEngine/theforceengine |
| 38 | +if [[ ! -s "$demo_path" || ! -f "$demo_path" ]]; then |
| 39 | + demo_path="$(dirname "$(realpath "$0")")"/Replays/base_test.demo |
| 40 | + if [ -f $demo_path ]; then |
| 41 | + echo "Found the demo at $demo_path" |
| 42 | + else |
| 43 | + echo "ERROR: Cannot find the demo file $demo_path. It should be in the TheForceEngine/Tests/Replays folder" |
| 44 | + exit 1 |
| 45 | + fi |
| 46 | +fi |
14 | 47 |
|
15 |
| -# Run the demo and generate new log file |
16 |
| -echo "running tfe" |
17 |
| -$root_path/TheForceEngine/theforceengine -gDark -r$root_path/Tests/Replays/base_test.demo --demo_logging --exit_after_replay |
18 |
| -echo "Result is "$? |
19 |
| -echo "Done running tfe" |
| 48 | +# Path to the demo log file |
| 49 | +demo_log_path="" |
20 | 50 |
|
21 |
| -if [ -f $root_path/TheForceEngine/theforceengine ]; then |
22 |
| - echo "dump exists" |
23 |
| -else |
24 |
| - echo "no dump exists" |
25 |
| -fi |
| 51 | +if [[ ! -s "$demo_log_path" || ! -f "$demo_log_path" ]]; then |
| 52 | + demo_log_path="$(dirname "$(realpath "$0")")"/Replays/base_replay_log.txt |
| 53 | + if [ -f $demo_log_path ]; then |
| 54 | + echo "Found the demo log at $demo_log_path" |
| 55 | + else |
| 56 | + echo "ERROR: Cannot find the demo log file $demo_log_path. It should be in the TheForceEngine/Tests/Replays folder" |
| 57 | + exit 1 |
| 58 | + fi |
| 59 | +fi |
26 | 60 |
|
27 |
| -echo "running tfe2" |
28 |
| -$root_path/theforceengine -gDark -r$root_path/Tests/Replays/base_test.demo --demo_logging --exit_after_replay |
29 |
| -echo "Result is "$? |
30 |
| -echo "Done running tfe" |
| 61 | +# Run the demo and generate new log file |
| 62 | +pushd $root_path |
| 63 | +echo "Running TFE test..." |
| 64 | +echo "Executing Command $root_path/theforceengine -gDark -r$demo_path --demo_logging --exit_after_replay ....." |
| 65 | +$root_path/theforceengine -gDark -r$demo_path --demo_logging --exit_after_replay |
| 66 | +result=$? |
| 67 | +echo "Done running test. Result is $result" |
31 | 68 |
|
| 69 | +if [ $result != "0" ]; then |
| 70 | + echo "ERROR: TFE failed to run. Please look at the logs hopefully generated in $user_doc_path" |
| 71 | + exit 1 |
| 72 | +fi |
| 73 | + |
| 74 | +# Diff Log Results of the test replay.log and the base one. |
32 | 75 |
|
33 |
| -#find / -type d -iname the_force_engine_log.txt 2>/dev/null | xargs cat |
| 76 | +if [ ! -f $user_doc_path/replay.log ]; then |
| 77 | + echo "ERROR: Missing $user_doc_path/replay.log - No log generated?" |
| 78 | + exit 1 |
| 79 | +fi |
34 | 80 |
|
35 |
| -top -b -n 1 | head -n 20 |
| 81 | +if [ ! -f $demo_log_path ]; then |
| 82 | + echo "ERROR: Missing $demo_log_path - did you not checkout the latest code?" |
| 83 | + exit 1 |
| 84 | +fi |
36 | 85 |
|
37 |
| -# Diff Results of the rest |
38 |
| -result=`diff <(tail -n 1 $user_path/.local/share/TheForceEngine/replay.log) <(tail -n 1 $root_path/TheForceEngine/Tests/Replays/base_replay_log.txt)` |
| 86 | +result=`diff <(tail -n 1 $user_doc_path/replay.log) <(tail -n 1 $demo_log_path)` |
39 | 87 |
|
40 | 88 | if $result > /dev/null; then
|
41 |
| - echo "RESULTS MATCH!" |
| 89 | + echo "TEST SUCCEEDED RESULTS MATCH!" |
42 | 90 | exit 0
|
43 | 91 | else
|
44 |
| - echo "RESULTS DO NOT MATCH!" |
| 92 | + echo "ERROR: RESULTS DO NOT MATCH!" |
45 | 93 | echo $result
|
46 | 94 | exit 1
|
47 | 95 | fi
|
48 |
| - |
|
0 commit comments