Path: blob/21.2-virgl/src/amd/compiler/tests/framework.h
7097 views
/*1* Copyright © 2020 Valve Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*22*/23#ifndef ACO_TEST_COMMON_H24#define ACO_TEST_COMMON_H25#include <map>26#include <string>27#include <stdio.h>2829#include "amd_family.h"30#include "aco_ir.h"31#include "aco_builder.h"32#include "vulkan/radv_shader.h"3334struct TestDef {35const char *name;36const char *source_file;37void (*func)();38};3940extern std::map<std::string, TestDef> tests;41extern FILE *output;4243bool set_variant(const char *name);4445inline bool set_variant(chip_class cls, const char *rest="")46{47char buf[8+strlen(rest)];48if (cls != GFX10_3) {49snprintf(buf, sizeof(buf), "gfx%d%s", cls - GFX6 + 6, rest);50} else {51snprintf(buf, sizeof(buf), "gfx10_3%s", rest);52}53return set_variant(buf);54}5556void fail_test(const char *fmt, ...);57void skip_test(const char *fmt, ...);5859#define _PASTE(a, b) a##b60#define PASTE(a, b) _PASTE(a, b)6162#define _BEGIN_TEST(name, struct_name) static void struct_name(); static __attribute__((constructor)) void PASTE(add_test_, __COUNTER__)() {\63tests[#name] = (TestDef){#name, ACO_TEST_BUILD_ROOT "/" __FILE__, &struct_name};\64}\65static void struct_name() {\6667#define BEGIN_TEST(name) _BEGIN_TEST(name, PASTE(Test_, __COUNTER__))68#define BEGIN_TEST_TODO(name) _BEGIN_TEST(name, PASTE(Test_, __COUNTER__))69#define BEGIN_TEST_FAIL(name) _BEGIN_TEST(name, PASTE(Test_, __COUNTER__))70#define END_TEST \71}7273#endif /* ACO_TEST_COMMON_H */747576