aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/sort/main.c
diff options
context:
space:
mode:
authorCyril SIX <cyril.six@kalray.eu>2018-11-14 11:49:34 +0100
committerCyril SIX <cyril.six@kalray.eu>2018-11-14 11:49:34 +0100
commita220a09ae6ce52400a563ea6ee65aa36b2ea9dfb (patch)
tree680798b800e104d0e766a3ab7a0f39469b2671fa /test/mppa/sort/main.c
parent0b86431038c1e874d7d7030ab41a8f56b0a9991f (diff)
parent154230f3d9cad4f8de59e8fcaa9d0fe4ae151a98 (diff)
downloadcompcert-kvx-a220a09ae6ce52400a563ea6ee65aa36b2ea9dfb.tar.gz
compcert-kvx-a220a09ae6ce52400a563ea6ee65aa36b2ea9dfb.zip
Merge branch 'mppa_asmbloc_nobreg' into mppa_k1c
Conflicts: mppa_k1c/Asm.v mppa_k1c/Asmexpand.ml mppa_k1c/TargetPrinter.ml test/mppa/Makefile test/mppa/builtins/clzll.c test/mppa/generate.sh
Diffstat (limited to 'test/mppa/sort/main.c')
-rw-r--r--test/mppa/sort/main.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/mppa/sort/main.c b/test/mppa/sort/main.c
new file mode 100644
index 00000000..aef419aa
--- /dev/null
+++ b/test/mppa/sort/main.c
@@ -0,0 +1,34 @@
+#include "../prng/prng.h"
+#include "../prng/types.h"
+
+#include "test.h"
+#include "insertion.h"
+#include "selection.h"
+#include "merge.h"
+
+int main(void){
+ uint64_t T[SIZE];
+ uint64_t res1[SIZE], res2[SIZE], res3[SIZE];
+ int i;
+ srand(42);
+
+ for (i = 0 ; i < SIZE ; i++)
+ T[i] = randlong();
+
+ /* insertion sort */
+ if (insert_sort(res1, T) < 0) return -1;
+
+ /* selection sort */
+ if (select_sort(res2, T) < 0) return -2;
+
+ /* merge sort */
+ if (merge_sort(res3, T) < 0) return -3;
+
+ /* We should have: res1[i] == res2[i] == res3[i] */
+ for (i = 0 ; i < SIZE ; i++){
+ if (!(res1[i] == res2[i] && res2[i] == res3[i]))
+ return -4;
+ }
+
+ return 0;
+}