diff --git a/make.sh b/make.sh index 0184f13..b727acf 100755 --- a/make.sh +++ b/make.sh @@ -19,14 +19,16 @@ if [[ $1 == "build" ]]; then echo "Fait." exit 0 elif [[ $2 == "test" ]]; then - for i in $(ls test); do - echo "Compilation de test/$i" - gcc "test/$i" -o "$OUT/test_$(echo $i | awk -F. '{print $1}')" $FLAGS + for i in "test/"*".c"; do + echo "Compilation de $i" + gcc "$i" -o "$OUT/test_$(echo $i | awk -F. '{print $1}' | awk -F/ '{print $NF}')" $FLAGS echo "Fait." done exit 0 elif [[ $2 == "utils" ]]; then + echo "Compilation de src/mnist/utils.c" gcc "src/mnist/utils.c" -o "$OUT/utils" $FLAGS + echo "Fait." exit 0 else $0 build main @@ -63,6 +65,11 @@ if [[ $1 == "test" ]]; then echo "--- $i ---" $i done + for i in "test/"*".sh"; do + echo "--- $i ---" + chmod +x "$i" + "$i" "$OUT" "$0" + done exit 0 fi fi diff --git a/src/mnist/utils.c b/src/mnist/utils.c index b6a9168..3965081 100644 --- a/src/mnist/utils.c +++ b/src/mnist/utils.c @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) { filename = ".cache/reseau.bin"; } print_weights(filename); - exit(1); + exit(0); } else if (! strcmp(argv[1], "print-biais")) { char* filename = NULL; int i = 2; @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) { filename = ".cache/reseau.bin"; } print_bias(filename); - exit(1); + exit(0); } else if (! strcmp(argv[1], "creer-reseau")) { char* out = NULL; int n = -1; @@ -175,7 +175,7 @@ int main(int argc, char* argv[]) { } } create_network(out, n); - exit(1); + exit(0); } else if (! strcmp(argv[1], "count-labels")) { char* labels = NULL; int i = 2; @@ -193,7 +193,7 @@ int main(int argc, char* argv[]) { labels = "data/mnist/train-labels-idx1-ubyte"; } count_labels(labels); - exit(1); + exit(0); } printf("Option choisie non reconnue: %s\n", argv[1]); help(argv[0]); diff --git a/test/neuron_io.c b/test/neuron_io.c index 8c52901..d7817eb 100644 --- a/test/neuron_io.c +++ b/test/neuron_io.c @@ -59,8 +59,16 @@ Network* create_network(int nb_layers, int nb_max_neurons, int nb_min_neurons) { } int main() { + printf("Création du réseau\n"); Network* network = create_network(5, 300, 10); + printf("OK\n"); + + printf("Écriture du réseau\n"); 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"); + printf("OK\n"); return 0; } \ No newline at end of file diff --git a/test/test_utils.sh b/test/test_utils.sh new file mode 100755 index 0000000..3b0b6b7 --- /dev/null +++ b/test/test_utils.sh @@ -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" \ No newline at end of file