diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | README.md | 10 | ||||
| -rw-r--r-- | shell/shell.c (renamed from shell.c) | 2 | ||||
| -rwxr-xr-x | shell/test.sh | 22 | ||||
| -rw-r--r-- | shell/testcases/000_frommoves.in | 1 | ||||
| -rw-r--r-- | shell/testcases/000_frommoves.out | 1 | ||||
| -rw-r--r-- | shell/testcases/001_compose.in | 1 | ||||
| -rw-r--r-- | shell/testcases/001_compose.out | 1 | ||||
| -rwxr-xr-x | test/test.sh | 2 |
10 files changed, 44 insertions, 7 deletions
| @@ -8,6 +8,8 @@ utils/.DS_Store | |||
| 8 | perf.data | 8 | perf.data |
| 9 | perf.data.old | 9 | perf.data.old |
| 10 | run | 10 | run |
| 11 | shell/lasttest.out | ||
| 12 | shell/lasttest.err | ||
| 11 | tables/* | 13 | tables/* |
| 12 | test/*/runtest | 14 | test/*/runtest |
| 13 | test/.DS_Store | 15 | test/.DS_Store |
| @@ -30,10 +30,13 @@ debugtool: debugnissy.o | |||
| 30 | 30 | ||
| 31 | shell: nissy.o | 31 | shell: nissy.o |
| 32 | mkdir -p tables | 32 | mkdir -p tables |
| 33 | ${CC} ${MACROS} ${CFLAGS} -o run nissy.o shell.c | 33 | ${CC} ${MACROS} ${CFLAGS} -o run nissy.o shell/shell.c |
| 34 | 34 | ||
| 35 | debugshell: debugnissy.o | 35 | debugshell: debugnissy.o |
| 36 | mkdir -p tables | 36 | mkdir -p tables |
| 37 | ${CC} ${MACROS} ${DBGFLAGS} -o run debugnissy.o shell.c | 37 | ${CC} ${MACROS} ${DBGFLAGS} -o run debugnissy.o shell/shell.c |
| 38 | 38 | ||
| 39 | .PHONY: all clean test tool debugtool shell debugshell | 39 | shelltest: debugshell |
| 40 | ./shell/test.sh | ||
| 41 | |||
| 42 | .PHONY: all clean test tool debugtool shell debugshell shelltest | ||
| @@ -108,8 +108,14 @@ commands manually. To build the shell use: | |||
| 108 | $ make shell | 108 | $ make shell |
| 109 | ``` | 109 | ``` |
| 110 | 110 | ||
| 111 | This will create an executable called `run`. Then you can for example | 111 | This will create an executable called `run`. |
| 112 | get a cube from a sequence of moves: | 112 | Optionally, you can run some tests: |
| 113 | |||
| 114 | ``` | ||
| 115 | $ make shelltest | ||
| 116 | ``` | ||
| 117 | |||
| 118 | Then you can for example get a cube from a sequence of moves: | ||
| 113 | 119 | ||
| 114 | ``` | 120 | ``` |
| 115 | $ ./run frommoves -moves "R' U' F" | 121 | $ ./run frommoves -moves "R' U' F" |
| @@ -7,7 +7,7 @@ | |||
| 7 | #include <string.h> | 7 | #include <string.h> |
| 8 | #include <time.h> | 8 | #include <time.h> |
| 9 | 9 | ||
| 10 | #include "src/nissy.h" | 10 | #include "../src/nissy.h" |
| 11 | 11 | ||
| 12 | #define PRINTCUBE_BUFFER_SIZE UINT64_C(1024) | 12 | #define PRINTCUBE_BUFFER_SIZE UINT64_C(1024) |
| 13 | #define SOLUTIONS_BUFFER_SIZE UINT64_C(500000) | 13 | #define SOLUTIONS_BUFFER_SIZE UINT64_C(500000) |
diff --git a/shell/test.sh b/shell/test.sh new file mode 100755 index 0000000..de888ef --- /dev/null +++ b/shell/test.sh | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | SHELLBIN="./run" | ||
| 4 | TESTDIR="./shell/testcases" | ||
| 5 | TESTOUT="shell/lasttest.out" | ||
| 6 | TESTERR="shell/lasttest.err" | ||
| 7 | |||
| 8 | for cin in "$TESTDIR"/*.in; do | ||
| 9 | c=$(echo "$cin" | sed 's/\.in//') | ||
| 10 | cout="$c.out" | ||
| 11 | printf "%s: " "$c" | ||
| 12 | (cat "$cin" | xargs "$SHELLBIN") > $TESTOUT 2> $TESTERR | ||
| 13 | if diff "$cout" "$TESTOUT"; then | ||
| 14 | printf "OK\n" | ||
| 15 | else | ||
| 16 | printf "Test failed! stderr:\n" | ||
| 17 | cat $TESTERR | ||
| 18 | exit 1 | ||
| 19 | fi | ||
| 20 | done | ||
| 21 | |||
| 22 | echo "All tests passed!" | ||
diff --git a/shell/testcases/000_frommoves.in b/shell/testcases/000_frommoves.in new file mode 100644 index 0000000..2b3c6d1 --- /dev/null +++ b/shell/testcases/000_frommoves.in | |||
| @@ -0,0 +1 @@ | |||
| frommoves -moves "UFRR" | |||
diff --git a/shell/testcases/000_frommoves.out b/shell/testcases/000_frommoves.out new file mode 100644 index 0000000..dfefe81 --- /dev/null +++ b/shell/testcases/000_frommoves.out | |||
| @@ -0,0 +1 @@ | |||
| DEOISVBH=ZFCYHAGBLTKU | |||
diff --git a/shell/testcases/001_compose.in b/shell/testcases/001_compose.in new file mode 100644 index 0000000..fa09a0b --- /dev/null +++ b/shell/testcases/001_compose.in | |||
| @@ -0,0 +1 @@ | |||
| compose -cube NEORSQLH=ZFCYUAGLHTKB -perm NEORSQLH=ZFCYUAGLHTKB | |||
diff --git a/shell/testcases/001_compose.out b/shell/testcases/001_compose.out new file mode 100644 index 0000000..d36a93c --- /dev/null +++ b/shell/testcases/001_compose.out | |||
| @@ -0,0 +1 @@ | |||
| ASTUGFBH=DACXEZGBLIKF | |||
diff --git a/test/test.sh b/test/test.sh index a675286..8b5db35 100755 --- a/test/test.sh +++ b/test/test.sh | |||
| @@ -10,7 +10,7 @@ for t in test/*; do | |||
| 10 | if [ -n "$re" ] && !(echo "$t" | grep -q "$re"); then | 10 | if [ -n "$re" ] && !(echo "$t" | grep -q "$re"); then |
| 11 | continue | 11 | continue |
| 12 | fi | 12 | fi |
| 13 | 13 | ||
| 14 | # Verify if $t is a directory and if its name starts with three digits | 14 | # Verify if $t is a directory and if its name starts with three digits |
| 15 | if [ -d "$t" ] && basename "$t" | grep -Eq '^[0-9]{3}'; then | 15 | if [ -d "$t" ] && basename "$t" | grep -Eq '^[0-9]{3}'; then |
| 16 | $CC -o $TESTBIN "$t"/*.c $OBJ || exit 1 | 16 | $CC -o $TESTBIN "$t"/*.c $OBJ || exit 1 |
