Skip to content

Commit 508872f

Browse files
committed
Disable RV32 tests if RV32 is not supported in the toolchain
1 parent 2ea65d9 commit 508872f

File tree

10 files changed

+60
-5
lines changed

10 files changed

+60
-5
lines changed

test/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ macro(add_rev_test test_name test_dir timeout labels)
149149
)
150150
add_test(NAME ${test_name_lower}_revmem_${numHarts}_harts_${numCores}_cores COMMAND ${CMAKE_COMMAND} --build . --target run_${test_name_lower}_revmem_${numHarts}_harts_${numCores}_cores)
151151

152+
if((NOT ${rv32_label_index} EQUAL -1) AND DEFINED RV32_DISABLED)
153+
set_tests_properties(${test_name_lower}_revmem_${numHarts}_harts_${numCores}_cores PROPERTIES DISABLED TRUE)
154+
endif()
155+
152156
# If 'memh' label found, add a memHierarchy test
153157
if(add_memh_test)
154158
add_custom_target(run_${test_name_lower}_memh_${numHarts}_harts_${numCores}_cores
@@ -157,6 +161,10 @@ macro(add_rev_test test_name test_dir timeout labels)
157161
COMMENT "Running ${test_name_lower} test with memHierarchy enabled, numHarts=${numHarts}, numCores=${numCores}"
158162
)
159163
add_test(NAME ${test_name_lower}_memh_${numHarts}_harts_${numCores}_cores COMMAND ${CMAKE_COMMAND} --build . --target run_${test_name_lower}_memh_${numHarts}_harts_${numCores}_cores)
164+
if((NOT ${rv32_label_index} EQUAL -1) AND DEFINED RV32_DISABLED)
165+
set_tests_properties(${test_name_lower}_memh_${numHarts}_harts_${numCores}_cores PROPERTIES DISABLED TRUE)
166+
endif()
167+
160168
endif()
161169

162170
set_tests_properties(${test_name_lower}_revmem_${numHarts}_harts_${numCores}_cores
@@ -199,10 +207,22 @@ macro(add_rev_test test_name test_dir timeout labels)
199207
PASS_REGULAR_EXPRESSION "${passRegex}"
200208
LABELS "${labels}"
201209
)
210+
if((NOT ${rv32_label_index} EQUAL -1) AND DEFINED RV32_DISABLED)
211+
set_tests_properties(${test_name_lower}_script PROPERTIES DISABLED TRUE)
212+
endif()
202213
endif()
203214
endif()
204215
endmacro()
205216

217+
# Not all toolchains have support RV32, so we test and skip RV32 tests with a warning
218+
execute_process(COMMAND ${RVCC} -march=rv32i -mabi=ilp32 -o /dev/null ex1.c WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/ex1 ERROR_VARIABLE RV32_Missing ECHO_ERROR_VARIABLE COMMAND_ECHO STDERR)
219+
if(RV32_Missing MATCHES "Cannot find suitable multilib set for '-march=rv32")
220+
set(RV32_DISABLED TRUE)
221+
message(WARNING "RV32 tests disabled because ${RVCC} does not support RV32:\n${RV32_Missing}")
222+
else()
223+
message(STATUS "RV32 tests enabled")
224+
endif()
225+
206226
# add_rev_test(test_name test_dir timeout labels)
207227
add_rev_test(EXT_VERSION ext_version 20 "rv64")
208228
add_rev_test(EX1 ex1 30 "memh;rv32")

test/coproc_ex/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
EXAMPLE=coproc_ex
1616
CC="${RVCC}"
17-
ARCH=rv64imafd
17+
ARCH=rv64gc
1818
#ABI=lp64
1919

2020
all: $(EXAMPLE).exe

test/csr/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
EXAMPLE=csr
1414
CXX="${RVCXX}"
15-
ARCH=rv64g
15+
ARCH=rv64gc
1616
ABI=lp64d
1717

1818
CFLAGS=-I ../../common/syscalls -O1

test/rdcycle/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
EXAMPLE=rdcycle
1414
CC="${RVCC}"
15-
ARCH=rv64g
15+
ARCH=rv64gc
1616
ABI=lp64d
1717

1818
CFLAGS=-I ../../common/syscalls -O1

test/rdcycle/rdcycle.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define NOP512 NOP256 NOP256
2727
#define NOP1024 NOP512 NOP512
2828

29+
#define VERBOSE 0
30+
2931
int main( int argc, char** argv ) {
3032
size_t cycle1, cycle2;
3133

@@ -39,9 +41,11 @@ int main( int argc, char** argv ) {
3941

4042
size_t diff = cycle2 - cycle1;
4143

44+
#if VERBOSE
4245
char cycles[64];
4346
snprintf( cycles, sizeof( cycles ), "%zu cycles\n", diff );
4447
rev_write( 1, cycles, strlen( cycles ) );
48+
#endif
4549

4650
// Make sure the number of cycles is between 1024 and 1026
4751
if( diff < 1024 || diff > 1026 )
@@ -58,9 +62,11 @@ int main( int argc, char** argv ) {
5862

5963
size_t diff = cycle2 - cycle1;
6064

65+
#if VERBOSE
6166
char cycles[64];
6267
snprintf( cycles, sizeof( cycles ), "%zu cycles\n", diff );
6368
rev_write( 1, cycles, strlen( cycles ) );
69+
#endif
6470

6571
// Make sure the number of cycles is between 1024 and 1026
6672
if( diff < 1024 || diff > 1026 )
@@ -77,9 +83,11 @@ int main( int argc, char** argv ) {
7783

7884
size_t diff = cycle2 - cycle1;
7985

86+
#if VERBOSE
8087
char cycles[64];
8188
snprintf( cycles, sizeof( cycles ), "%zu cycles\n", diff );
8289
rev_write( 1, cycles, strlen( cycles ) );
90+
#endif
8391

8492
// Make sure the number of cycles is between 1024 and 1026
8593
if( diff < 1024 || diff > 1026 )
@@ -96,9 +104,11 @@ int main( int argc, char** argv ) {
96104

97105
size_t diff = cycle2 - cycle1;
98106

107+
#if VERBOSE
99108
char cycles[64];
100109
snprintf( cycles, sizeof( cycles ), "%zu cycles\n", diff );
101110
rev_write( 1, cycles, strlen( cycles ) );
111+
#endif
102112

103113
// Make sure the number of cycles is between 1024 and 1026
104114
if( diff < 1024 || diff > 1026 )

test/rdinstret/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
EXAMPLE=rdinstret
1414
CC="${RVCC}"
15-
ARCH=rv64g
15+
ARCH=rv64gc
1616
ABI=lp64d
1717

1818
CFLAGS=-I ../../common/syscalls -O1

test/rdinstret/rdinstret.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define NOP512 NOP256 NOP256
2727
#define NOP1024 NOP512 NOP512
2828

29+
#define VERBOSE 0
30+
2931
int main( int argc, char** argv ) {
3032
size_t retired1, retired2;
3133

@@ -39,9 +41,11 @@ int main( int argc, char** argv ) {
3941

4042
size_t diff = retired2 - retired1;
4143

44+
#if VERBOSE
4245
char retired[64];
4346
snprintf( retired, sizeof( retired ), "%zu instructions retired\n", diff );
4447
rev_write( 1, retired, strlen( retired ) );
48+
#endif
4549

4650
// Make sure the instructions retired is between 1024 and 1026
4751
if( diff < 1024 || diff > 1026 )
@@ -58,9 +62,11 @@ int main( int argc, char** argv ) {
5862

5963
size_t diff = retired2 - retired1;
6064

65+
#if VERBOSE
6166
char retired[64];
6267
snprintf( retired, sizeof( retired ), "%zu instructions retired\n", diff );
6368
rev_write( 1, retired, strlen( retired ) );
69+
#endif
6470

6571
// Make sure the instructions retired is between 1024 and 1026
6672
if( diff < 1024 || diff > 1026 )
@@ -77,9 +83,11 @@ int main( int argc, char** argv ) {
7783

7884
size_t diff = retired2 - retired1;
7985

86+
#if VERBOSE
8087
char retired[64];
8188
snprintf( retired, sizeof( retired ), "%zu instructions retired\n", diff );
8289
rev_write( 1, retired, strlen( retired ) );
90+
#endif
8391

8492
// Make sure the instructions retired is between 1024 and 1026
8593
if( diff < 1024 || diff > 1026 )
@@ -96,9 +104,11 @@ int main( int argc, char** argv ) {
96104

97105
size_t diff = retired2 - retired1;
98106

107+
#if VERBOSE
99108
char retired[64];
100109
snprintf( retired, sizeof( retired ), "%zu instructions retired\n", diff );
101110
rev_write( 1, retired, strlen( retired ) );
111+
#endif
102112

103113
// Make sure the instructions retired is between 1024 and 1026
104114
if( diff < 1024 || diff > 1026 )

test/rdtime/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
EXAMPLE=rdtime
1414
CC="${RVCC}"
15-
ARCH=rv64g
15+
ARCH=rv64gc
1616
ABI=lp64d
1717

1818
CFLAGS=-I ../../common/syscalls -O1

test/rdtime/rdtime.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#define NOP512 NOP256 NOP256
2727
#define NOP1024 NOP512 NOP512
2828

29+
#define VERBOSE 0
30+
2931
int main( int argc, char** argv ) {
3032
size_t time1, time2;
3133

@@ -39,9 +41,11 @@ int main( int argc, char** argv ) {
3941

4042
size_t diff = time2 - time1;
4143

44+
#if VERBOSE
4245
char time[64];
4346
snprintf( time, sizeof( time ), "%zu time\n", diff );
4447
rev_write( 1, time, strlen( time ) );
48+
#endif
4549

4650
// Make sure the time is between 1024 and 1026
4751
if( diff < 1024 || diff > 1026 )
@@ -58,9 +62,11 @@ int main( int argc, char** argv ) {
5862

5963
size_t diff = time2 - time1;
6064

65+
#if VERBOSE
6166
char time[64];
6267
snprintf( time, sizeof( time ), "%zu time\n", diff );
6368
rev_write( 1, time, strlen( time ) );
69+
#endif
6470

6571
// Make sure the time is between 1024 and 1026
6672
if( diff < 1024 || diff > 1026 )
@@ -77,9 +83,11 @@ int main( int argc, char** argv ) {
7783

7884
size_t diff = time2 - time1;
7985

86+
#if VERBOSE
8087
char time[64];
8188
snprintf( time, sizeof( time ), "%zu time\n", diff );
8289
rev_write( 1, time, strlen( time ) );
90+
#endif
8391

8492
// Make sure the time is between 1024 and 1026
8593
if( diff < 1024 || diff > 1026 )
@@ -96,9 +104,11 @@ int main( int argc, char** argv ) {
96104

97105
size_t diff = time2 - time1;
98106

107+
#if VERBOSE
99108
char time[64];
100109
snprintf( time, sizeof( time ), "%zu time\n", diff );
101110
rev_write( 1, time, strlen( time ) );
111+
#endif
102112

103113
// Make sure the time is between 1024 and 1026
104114
if( diff < 1024 || diff > 1026 )

test/syscalls/perf_stats/perf_stats.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <stdio.h>
33
#include <string.h>
44

5+
#define VERBOSE 0
6+
57
void print( const char* prefix, unsigned long x ) {
68
char buf[256];
79
sprintf( buf, "%s%lu\n", prefix, x );
@@ -16,7 +18,10 @@ int main( int argc, char* argv[] ) {
1618
ret++;
1719
rev_perf_stats( &rs2 );
1820

21+
#if VERBOSE
1922
print( "instructions: ", rs2.instructions - rs1.instructions );
2023
print( "cycles: ", rs2.cycles - rs1.cycles );
24+
#endif
25+
2126
return ret;
2227
}

0 commit comments

Comments
 (0)