commit 41e31b84a9adeae0b6bdbc4c9438bfa5e782c9da parent 4444e53eaadf33aa309a40849730be332ca6d0de Author: Sebastiano Tronto <sebastiano@tronto.net> Date: Mon, 13 Nov 2023 23:47:00 +0100 Test cleanup Diffstat:
27 files changed, 56 insertions(+), 542 deletions(-)
diff --git a/.gitignore b/.gitignore @@ -1,5 +1,6 @@ config.mk benchmark/results +old/benchmark/results benchmark/run test/*/runtest test/run diff --git a/TODO.txt b/TODO.txt @@ -21,6 +21,7 @@ See the sections below for details ## Small change +* solve tests: make smaller, split * add lots of tests for things that were static, now visible ## Solving diff --git a/old/benchmark/results/results-2023-10-31-18-54-37.txt b/old/benchmark/results/results-2023-10-31-18-54-37.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UR0 -> moves: 3.5626s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 9.9028s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 2.9944s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: DB0 -> inv: 2.6475s - -Benchmark summary: -moves: 100000000 moves in 3.5626s (28.0697 MTPS) -trans: 100000000 trans in 9.9028s (10.0981 MTPS) -comp: 100000000 comps in 2.9944s (33.3956 MCPS) -inv: 100000000 invs in 2.6475s (37.7714 MIPS) -Total time: 19.1073 diff --git a/old/benchmark/results/results-2023-10-31-19-13-49.txt b/old/benchmark/results/results-2023-10-31-19-13-49.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UF0 -> moves: 3.5096s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 9.8367s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 2.9693s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: FL0 -> inv: 2.6227s - -Benchmark summary: -moves: 100000000 moves in 3.5096s (28.4930 MTPS) -trans: 100000000 trans in 9.8367s (10.1660 MTPS) -comp: 100000000 comps in 2.9693s (33.6784 MCPS) -inv: 100000000 invs in 2.6227s (38.1283 MIPS) -Total time: 18.9383 diff --git a/old/benchmark/results/results-2023-11-01-20-55-21.txt b/old/benchmark/results/results-2023-11-01-20-55-21.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: BL1 -> moves: 3.6556s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 7.5844s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 3.0103s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: DL0 -> inv: 2.6601s - -Benchmark summary: -moves: 100000000 moves in 3.6556s (27.3556 MTPS) -trans: 100000000 trans in 7.5844s (13.1850 MTPS) -comp: 100000000 comps in 3.0103s (33.2191 MCPS) -inv: 100000000 invs in 2.6601s (37.5929 MIPS) -Total time: 16.9103 diff --git a/old/benchmark/results/results-2023-11-03-23-08-50.txt b/old/benchmark/results/results-2023-11-03-23-08-50.txt @@ -1,18 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: ERR -> moves: 6.6791s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: ERR -> trans: 6.6844s - -> comp: setting up benchmark... -> comp: running benchmark... diff --git a/old/benchmark/results/results-2023-11-03-23-10-40.txt b/old/benchmark/results/results-2023-11-03-23-10-40.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: BL1 -> moves: 1.6354s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: ERR -> trans: 1.9863s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 0.3505s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: DL1 -> inv: 0.7249s - -Benchmark summary: -moves: 100000000 moves in 1.6354s (61.1463 MTPS) -trans: 100000000 trans in 1.9863s (50.3458 MTPS) -comp: 100000000 comps in 0.3505s (285.3105 MCPS) -inv: 100000000 invs in 0.7249s (137.9488 MIPS) -Total time: 4.6971 diff --git a/old/benchmark/results/results-2023-11-04-10-22-43.txt b/old/benchmark/results/results-2023-11-04-10-22-43.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UF0 -> moves: 1.3535s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 1.6526s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UR0 -> comp: 0.2848s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: DF0 -> inv: 0.6598s - -Benchmark summary: -moves: 100000000 moves in 1.3535s (73.8828 MTPS) -trans: 100000000 trans in 1.6526s (60.5112 MTPS) -comp: 100000000 comps in 0.2848s (351.1409 MCPS) -inv: 100000000 invs in 0.6598s (151.5679 MIPS) -Total time: 3.9506 diff --git a/old/benchmark/results/results-2023-11-04-10-23-11.txt b/old/benchmark/results/results-2023-11-04-10-23-11.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UL1 -> moves: 1.3463s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 1.6303s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 0.2881s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: UF0 -> inv: 0.6853s - -Benchmark summary: -moves: 100000000 moves in 1.3463s (74.2803 MTPS) -trans: 100000000 trans in 1.6303s (61.3400 MTPS) -comp: 100000000 comps in 0.2881s (347.0564 MCPS) -inv: 100000000 invs in 0.6853s (145.9211 MIPS) -Total time: 3.9499 diff --git a/old/benchmark/results/results-2023-11-04-10-23-43.txt b/old/benchmark/results/results-2023-11-04-10-23-43.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UF0 -> moves: 1.3434s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 1.6439s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UR1 -> comp: 0.2872s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: DF0 -> inv: 0.6646s - -Benchmark summary: -moves: 100000000 moves in 1.3434s (74.4399 MTPS) -trans: 100000000 trans in 1.6439s (60.8320 MTPS) -comp: 100000000 comps in 0.2872s (348.1848 MCPS) -inv: 100000000 invs in 0.6646s (150.4726 MIPS) -Total time: 3.9390 diff --git a/old/benchmark/results/results-2023-11-04-10-24-08.txt b/old/benchmark/results/results-2023-11-04-10-24-08.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UF0 -> moves: 1.3330s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 1.6094s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 0.2827s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: BL0 -> inv: 0.6527s - -Benchmark summary: -moves: 100000000 moves in 1.3330s (75.0200 MTPS) -trans: 100000000 trans in 1.6094s (62.1335 MTPS) -comp: 100000000 comps in 0.2827s (353.7582 MCPS) -inv: 100000000 invs in 0.6527s (153.2026 MIPS) -Total time: 3.8778 diff --git a/old/benchmark/results/results-2023-11-04-10-52-05.txt b/old/benchmark/results/results-2023-11-04-10-52-05.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UL0 -> moves: 3.6559s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 7.9072s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: BL1 -> comp: 3.3698s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: FL1 -> inv: 2.6933s - -Benchmark summary: -moves: 100000000 moves in 3.6559s (27.3528 MTPS) -trans: 100000000 trans in 7.9072s (12.6467 MTPS) -comp: 100000000 comps in 3.3698s (29.6755 MCPS) -inv: 100000000 invs in 2.6933s (37.1296 MIPS) -Total time: 17.6262 diff --git a/old/benchmark/results/results-2023-11-04-10-53-06.txt b/old/benchmark/results/results-2023-11-04-10-53-06.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UR1 -> moves: 1.3554s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 1.6302s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 0.2880s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: DR1 -> inv: 0.6567s - -Benchmark summary: -moves: 100000000 moves in 1.3554s (73.7816 MTPS) -trans: 100000000 trans in 1.6302s (61.3423 MTPS) -comp: 100000000 comps in 0.2880s (347.2758 MCPS) -inv: 100000000 invs in 0.6567s (152.2870 MIPS) -Total time: 3.9302 diff --git a/old/benchmark/results/results-2023-11-04-10-57-46.txt b/old/benchmark/results/results-2023-11-04-10-57-46.txt @@ -1,32 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMP: 100000000 -INV: 100000000 - -> moves: setting up benchmark... -> moves: running benchmark... -> moves: resulting cube, first piece: UL0 -> moves: 1.3518s - -> trans: setting up benchmark... -> trans: running benchmark... -> trans: resulting cube, first piece: UF0 -> trans: 1.6350s - -> comp: setting up benchmark... -> comp: running benchmark... -> comp: resulting cube, first piece: UF0 -> comp: 0.3039s - -> inv: setting up benchmark... -> inv: running benchmark... -> comp: resulting cube, first piece: UR1 -> inv: 0.6681s - -Benchmark summary: -moves: 100000000 moves in 1.3518s (73.9734 MTPS) -trans: 100000000 trans in 1.6350s (61.1621 MTPS) -comp: 100000000 comps in 0.3039s (329.0593 MCPS) -inv: 100000000 invs in 0.6681s (149.6737 MIPS) -Total time: 3.9589 diff --git a/old/benchmark/results/results-2023-11-10-15-49-45.txt b/old/benchmark/results/results-2023-11-10-15-49-45.txt @@ -1,28 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMPOSE: 100000000 -INVERSE: 100000000 - -> moves: running benchmark... -> moves: resulting cube, first piece: UB0 -> moves: 0.0097s - -> trans: running benchmark... -> trans: resulting cube, first piece: DB0 -> trans: 20.1464s - -> compose: running benchmark... -> compose: resulting cube, first piece: ERR -> compose: 3.7322s - -> inverse: running benchmark... -> inverse: resulting cube, first piece: DB0 -> inverse: 2.1003s - -Benchmark summary: -moves: 100000000 moves in 0.0097s (10259.5134 MTPS) -trans: 100000000 transformations in 20.1464s (4.9637 MTPS) -compose: 100000000 compositions in 3.7322s (26.7940 MCPS) -inverse: 100000000 inverses in 2.1003s (47.6116 MIPS) -Total time: 25.9886 diff --git a/old/benchmark/results/results.txt b/old/benchmark/results/results.txt @@ -1,28 +0,0 @@ -Benchmarks settings: -MOVES: 100000000 -TRANS: 100000000 -COMPOSE: 100000000 -INVERSE: 100000000 - -> moves: running benchmark... -> moves: resulting cube, first piece: UB0 -> moves: 0.0097s - -> trans: running benchmark... -> trans: resulting cube, first piece: DB0 -> trans: 20.1464s - -> compose: running benchmark... -> compose: resulting cube, first piece: ERR -> compose: 3.7322s - -> inverse: running benchmark... -> inverse: resulting cube, first piece: DB0 -> inverse: 2.1003s - -Benchmark summary: -moves: 100000000 moves in 0.0097s (10259.5134 MTPS) -trans: 100000000 transformations in 20.1464s (4.9637 MTPS) -compose: 100000000 compositions in 3.7322s (26.7940 MCPS) -inverse: 100000000 inverses in 2.1003s (47.6116 MIPS) -Total time: 25.9886 diff --git a/test/00_basic/basic_tests.c b/test/00_basic/basic_tests.c @@ -1,13 +1,7 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> +#include "../test.h" -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" +bool issolved(cube_t); +bool equal(cube_t, cube_t); void check(cube_t cube, char *name) @@ -19,7 +13,6 @@ check(cube_t cube, char *name) void check2(cube_t cube1, char *name1, cube_t cube2, char *name2) { -fprintf(stderr, "check2 %s %s\n", name1, name2); printf("%s and %s are%s equal\n", name1, name2, equal(cube1, cube2) ? "" : " NOT"); } diff --git a/test/010_io_H48_read_write/io_H48_tests.c b/test/010_io_H48_read_write/io_H48_tests.c @@ -1,14 +1,4 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> - -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define STRLENMAX 10000 +#include "../test.h" int main() { char *c, str[STRLENMAX]; diff --git a/test/011_io_SRC_write/io_SRC_tests.c b/test/011_io_SRC_write/io_SRC_tests.c @@ -1,14 +1,4 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> - -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define STRLENMAX 10000 +#include "../test.h" int main() { char *c, str[STRLENMAX]; diff --git a/test/012_io_AVX_write/io_AVX_tests.c b/test/012_io_AVX_write/io_AVX_tests.c @@ -1,15 +1,12 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> - -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" +#include "../test.h" #define STRLENMAX 10000 +bool iserror(cube_t); +bool issolvable(cube_t); +cube_t readcube(char *, char *); +void writecube(char *, cube_t, char *); + int main() { char *c, str[STRLENMAX]; cube_t cube; diff --git a/test/020_move/move_tests.c b/test/020_move/move_tests.c @@ -1,15 +1,6 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> +#include "../test.h" -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define STRLENMAX 10000 -#define MOVESMAX 1000 +cube_t applymoves(cube_t, char *); int main() { char movestr[STRLENMAX], cubestr[STRLENMAX]; diff --git a/test/030_inverse_cube/inverse_tests.c b/test/030_inverse_cube/inverse_tests.c @@ -1,14 +1,6 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> +#include "../test.h" -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define STRLENMAX 10000 +cube_t inverse(cube_t); int main() { char str[STRLENMAX]; diff --git a/test/040_compose/compose_tests.c b/test/040_compose/compose_tests.c @@ -1,14 +1,6 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> +#include "../test.h" -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define STRLENMAX 10000 +cube_t compose(cube_t, cube_t); int main() { char str[STRLENMAX]; diff --git a/test/050_transform/transform_tests.c b/test/050_transform/transform_tests.c @@ -1,14 +1,6 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> +#include "../test.h" -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define STRLENMAX 10000 +cube_t applytrans(cube_t, char *); int main() { char cubestr[STRLENMAX], transtr[STRLENMAX]; diff --git a/test/061_coord_eo/coord_eo_tests.c b/test/061_coord_eo/coord_eo_tests.c @@ -1,15 +1,5 @@ -#include <stdbool.h> -#include <inttypes.h> -#include <stdio.h> - -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - #include "../test.h" -#define STRLENMAX 10000 - int64_t coord_fast_eo(cube_fast_t); cube_fast_t cubetofast(cube_t); diff --git a/test/070_solve_simple/solve_simple_tests.c b/test/070_solve_simple/solve_simple_tests.c @@ -1,33 +1,25 @@ -#include <stdbool.h> -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "../test.h" -#ifdef CUBE_AVX2 -#include <immintrin.h> -#endif - -#include "../../cube.h" - -#define S 10000 +int64_t solve(cube_t, char *, char *, char *, int8_t, int8_t, int64_t, int8_t, + void *, char *); int main() { - char cubestr[S], solverstr[S], optionsstr[S], nisstypestr[S]; - char minmovesstr[S], maxmovesstr[S], maxsolsstr[S], optimalstr[S]; - char solutionsstr[S]; + char cubestr[STRLENMAX], solverstr[STRLENMAX], optionsstr[STRLENMAX]; + char nisstypestr[STRLENMAX], minmovesstr[STRLENMAX]; + char maxmovesstr[STRLENMAX], maxsolsstr[STRLENMAX]; + char optimalstr[STRLENMAX], solutionsstr[STRLENMAX]; cube_t cube; int64_t maxsols; int8_t minmoves, maxmoves, optimal; - fgets(cubestr, S, stdin); - fgets(solverstr, S, stdin); - fgets(optionsstr, S, stdin); - fgets(nisstypestr, S, stdin); - fgets(minmovesstr, S, stdin); - fgets(maxmovesstr, S, stdin); - fgets(maxsolsstr, S, stdin); - fgets(optimalstr, S, stdin); + fgets(cubestr, STRLENMAX, stdin); + fgets(solverstr, STRLENMAX, stdin); + fgets(optionsstr, STRLENMAX, stdin); + fgets(nisstypestr, STRLENMAX, stdin); + fgets(minmovesstr, STRLENMAX, stdin); + fgets(maxmovesstr, STRLENMAX, stdin); + fgets(maxsolsstr, STRLENMAX, stdin); + fgets(optimalstr, STRLENMAX, stdin); solverstr[strcspn(solverstr, "\n")] = 0; optionsstr[strcspn(optionsstr, "\n")] = 0; diff --git a/test/test.h b/test/test.h @@ -1,7 +1,26 @@ -#include "../cube.h" +#include <inttypes.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define STRLENMAX 10000 + +typedef struct { + uint8_t corner[8]; + uint8_t edge[12]; +} cube_t; #ifdef CUBE_AVX2 +#include <immintrin.h> typedef __m256i cube_fast_t; #else typedef cube_t cube_fast_t; #endif + +/* Basic functions used in most tests */ +cube_t solvedcube(void); +bool iserror(cube_t); +bool issolvable(cube_t); +cube_t readcube(char *, char *); +void writecube(char *, cube_t, char *);