aco: add framework for unit testing
[mesa.git] / src / amd / compiler / tests / test_tests.cpp
1 /*
2 * Copyright © 2020 Valve Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 */
24 #include "helpers.h"
25 #include <stdio.h>
26
27 using namespace aco;
28
29 BEGIN_TEST_TODO(todo)
30 //!test!
31 fprintf(output, "woops!\n");
32 END_TEST
33
34 BEGIN_TEST_FAIL(expect_fail)
35 //!test!
36 fprintf(output, "woops!\n");
37 END_TEST
38
39 BEGIN_TEST(simple.1)
40 //! s_buffer_load_dwordx2 @s64(a)
41 fprintf(output, "s_buffer_load_dwordx2 s[6:7]\n");
42 //! s_add_u32 s#b0, s#a, 1
43 //! s_addc_u32 s#b1, s#a1, 0
44 //; success = int(b0) == 8
45 fprintf(output, "s_add_u32 s8, s6, 1\n");
46 fprintf(output, "s_addc_u32 s9, s7, 0\n");
47 //! s_buffer_store_dwordx2 @s64(b)
48 fprintf(output, "s_buffer_store_dwordx2 s[8:9]\n");
49 END_TEST
50
51 BEGIN_TEST(simple.2)
52 //~gfx[67]! test gfx67
53 //~gfx8! test gfx8
54 //~gfx9! test gfx9
55 //! test all
56 for (int cls = GFX6; cls <= GFX7; cls++) {
57 if (!set_variant((enum chip_class)cls))
58 continue;
59 fprintf(output, "test gfx67\n");
60 fprintf(output, "test all\n");
61 }
62
63 if (set_variant("gfx8")) {
64 fprintf(output, "test gfx8\n");
65 fprintf(output, "test all\n");
66 }
67
68 if (set_variant("gfx9")) {
69 fprintf(output, "test gfx9\n");
70 fprintf(output, "test all\n");
71 }
72 END_TEST
73
74 BEGIN_TEST(simple.3)
75 //; funcs['test'] = lambda a: a
76 //! @test(s_buffer_load_dwordx2) @s64(a)
77 fprintf(output, "s_buffer_load_dwordx2 s[6:7]\n");
78 END_TEST