Skip to content

Commit fb62823

Browse files
authored
[Comgr] Add test for status_string() API
1 parent 69c5925 commit fb62823

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

amd/comgr/test-lit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ add_comgr_lit_binary(spirv-translator c)
4343
add_comgr_lit_binary(compile-opencl-minimal c)
4444
add_comgr_lit_binary(spirv-to-reloc c)
4545
add_comgr_lit_binary(unbundle c)
46+
add_comgr_lit_binary(status-string c)
4647
add_comgr_lit_binary(data-action c)
4748

4849
add_dependencies(check-comgr test-lit)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===- status-string.c ----------------------------------------------------===//
2+
//
3+
// Part of Comgr, under the Apache License v2.0 with LLVM Exceptions. See
4+
// amd/comgr/LICENSE.TXT in this repository for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "amd_comgr.h"
10+
#include "common.h"
11+
#include <stdio.h>
12+
#include <stdlib.h>
13+
#include <string.h>
14+
15+
int main(int argc, char *argv[]) {
16+
const char *StatusString = malloc(sizeof(char) * 100);
17+
amd_comgr_(status_string(AMD_COMGR_STATUS_SUCCESS, &StatusString));
18+
if (strcmp(StatusString, "SUCCESS"))
19+
fail("incorrect status: expected 'SUCCESS', saw '%s'", StatusString);
20+
21+
amd_comgr_(status_string(AMD_COMGR_STATUS_ERROR, &StatusString));
22+
if (strcmp(StatusString, "ERROR"))
23+
fail("incorrect status: expected 'ERROR', saw '%s'", StatusString);
24+
25+
amd_comgr_(status_string(AMD_COMGR_STATUS_ERROR_INVALID_ARGUMENT,
26+
&StatusString));
27+
if (strcmp(StatusString, "INVALID_ARGUMENT")) {
28+
fail("incorrect status: expected 'INVALID_ARGUMENT', saw '%s'",
29+
StatusString);
30+
}
31+
32+
amd_comgr_(status_string(AMD_COMGR_STATUS_ERROR_OUT_OF_RESOURCES,
33+
&StatusString));
34+
if (strcmp(StatusString, "OUT_OF_RESOURCES")) {
35+
fail("incorrect status: expected 'OUT_OF_RESOURCES', saw '%s'",
36+
StatusString);
37+
}
38+
39+
fail_amd_comgr_(status_string(-1, &StatusString));
40+
free(StatusString);
41+
return 0;
42+
}

amd/comgr/test-lit/status-string.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// COM: Check the Comgr status string API
2+
// RUN: status-string

0 commit comments

Comments
 (0)