Update tests

This commit is contained in:
augustin64 2022-05-16 17:26:04 +02:00
parent 727ce5f705
commit dd0113e128
4 changed files with 44 additions and 7 deletions

13
make.sh
View File

@ -19,14 +19,16 @@ if [[ $1 == "build" ]]; then
echo "Fait." echo "Fait."
exit 0 exit 0
elif [[ $2 == "test" ]]; then elif [[ $2 == "test" ]]; then
for i in $(ls test); do for i in "test/"*".c"; do
echo "Compilation de test/$i" echo "Compilation de $i"
gcc "test/$i" -o "$OUT/test_$(echo $i | awk -F. '{print $1}')" $FLAGS gcc "$i" -o "$OUT/test_$(echo $i | awk -F. '{print $1}' | awk -F/ '{print $NF}')" $FLAGS
echo "Fait." echo "Fait."
done done
exit 0 exit 0
elif [[ $2 == "utils" ]]; then elif [[ $2 == "utils" ]]; then
echo "Compilation de src/mnist/utils.c"
gcc "src/mnist/utils.c" -o "$OUT/utils" $FLAGS gcc "src/mnist/utils.c" -o "$OUT/utils" $FLAGS
echo "Fait."
exit 0 exit 0
else else
$0 build main $0 build main
@ -63,6 +65,11 @@ if [[ $1 == "test" ]]; then
echo "--- $i ---" echo "--- $i ---"
$i $i
done done
for i in "test/"*".sh"; do
echo "--- $i ---"
chmod +x "$i"
"$i" "$OUT" "$0"
done
exit 0 exit 0
fi fi
fi fi

View File

@ -139,7 +139,7 @@ int main(int argc, char* argv[]) {
filename = ".cache/reseau.bin"; filename = ".cache/reseau.bin";
} }
print_weights(filename); print_weights(filename);
exit(1); exit(0);
} else if (! strcmp(argv[1], "print-biais")) { } else if (! strcmp(argv[1], "print-biais")) {
char* filename = NULL; char* filename = NULL;
int i = 2; int i = 2;
@ -157,7 +157,7 @@ int main(int argc, char* argv[]) {
filename = ".cache/reseau.bin"; filename = ".cache/reseau.bin";
} }
print_bias(filename); print_bias(filename);
exit(1); exit(0);
} else if (! strcmp(argv[1], "creer-reseau")) { } else if (! strcmp(argv[1], "creer-reseau")) {
char* out = NULL; char* out = NULL;
int n = -1; int n = -1;
@ -175,7 +175,7 @@ int main(int argc, char* argv[]) {
} }
} }
create_network(out, n); create_network(out, n);
exit(1); exit(0);
} else if (! strcmp(argv[1], "count-labels")) { } else if (! strcmp(argv[1], "count-labels")) {
char* labels = NULL; char* labels = NULL;
int i = 2; int i = 2;
@ -193,7 +193,7 @@ int main(int argc, char* argv[]) {
labels = "data/mnist/train-labels-idx1-ubyte"; labels = "data/mnist/train-labels-idx1-ubyte";
} }
count_labels(labels); count_labels(labels);
exit(1); exit(0);
} }
printf("Option choisie non reconnue: %s\n", argv[1]); printf("Option choisie non reconnue: %s\n", argv[1]);
help(argv[0]); help(argv[0]);

View File

@ -59,8 +59,16 @@ Network* create_network(int nb_layers, int nb_max_neurons, int nb_min_neurons) {
} }
int main() { int main() {
printf("Création du réseau\n");
Network* network = create_network(5, 300, 10); Network* network = create_network(5, 300, 10);
printf("OK\n");
printf("Écriture du réseau\n");
write_network(".test-cache/neuron_io.bin", network); write_network(".test-cache/neuron_io.bin", network);
printf("OK\n");
printf("Vérification de l'accès en lecture\n");
Network* network2 = read_network(".test-cache/neuron_io.bin"); Network* network2 = read_network(".test-cache/neuron_io.bin");
printf("OK\n");
return 0; return 0;
} }

22
test/test_utils.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -e
OUT="$1"
[[ -f "$OUT/utils" ]] || "$2" build utils
echo "Compte des labels"
"$OUT/utils" count-labels -l data/mnist/t10k-labels-idx1-ubyte > /dev/null
echo "OK"
echo "Création du réseau"
"$OUT/utils" creer-reseau -n 3 -n .test-cache/reseau.bin > /dev/null
echo "OK"
echo "Affichage poids"
"$OUT/utils" print-poids -r .test-cache/reseau.bin
echo "OK"
echo "Affichage biais"
"$OUT/utils" print-biais -r .test-cache/reseau.bin > /dev/null
echo "OK"