• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- subzero/crosstest/test_stacksave_main.c - Driver for tests ---------===//
2 //
3 //                        The Subzero Code Generator
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Driver for cross testing stacksave/stackrestore intrinsics.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 /* crosstest.py --test=test_stacksave.c --driver=test_stacksave_main.c \
15    --prefix=Subzero_ --output=test_stacksave */
16 
17 #include <inttypes.h>
18 #include <stdint.h>
19 #include <stdio.h>
20 
21 #include "test_stacksave.h"
22 DECLARE_TESTS()
DECLARE_TESTS(Subzero_)23 DECLARE_TESTS(Subzero_)
24 
25 int main(int argc, char *argv[]) {
26   size_t TotalTests = 0;
27   size_t Passes = 0;
28   size_t Failures = 0;
29   typedef uint32_t (*FuncType)(uint32_t, uint32_t, uint32_t);
30   static struct {
31     const char *Name;
32     FuncType FuncLlc;
33     FuncType FuncSz;
34   } Funcs[] = {{"test_basic_vla", test_basic_vla, Subzero_test_basic_vla},
35                {"test_vla_in_loop", test_vla_in_loop, Subzero_test_vla_in_loop},
36                {"test_two_vlas_in_loops", test_two_vlas_in_loops,
37                 Subzero_test_two_vlas_in_loops}};
38   const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
39   const uint32_t size_to_test = 128;
40   for (size_t f = 0; f < NumFuncs; ++f) {
41     for (uint32_t start = 0; start < size_to_test / 2; ++start) {
42       ++TotalTests;
43       uint32_t inc = (start / 10) + 1;
44       uint32_t llc_result = Funcs[f].FuncLlc(size_to_test, start, inc);
45       uint32_t sz_result = Funcs[f].FuncSz(size_to_test, start, inc);
46       if (llc_result == sz_result) {
47         ++Passes;
48       } else {
49         ++Failures;
50         printf("Failure %s: start=%" PRIu32 ", "
51                "llc=%" PRIu32 ", sz=%" PRIu32 "\n",
52                Funcs[f].Name, start, llc_result, sz_result);
53       }
54     }
55   }
56   printf("TotalTests=%zu Passes=%zu Failures=%zu\n", TotalTests, Passes,
57          Failures);
58   return Failures;
59 }
60