Tests: Fix Ubuntu24.04 clang test issues, and enable action (#5824)

This commit is contained in:
Wilson Snyder 2025-03-02 16:53:59 -05:00 committed by GitHub
parent d31bce915c
commit b54f897090
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 19 deletions

View File

@ -96,7 +96,13 @@ jobs:
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: dist-vlt-3} - {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: dist-vlt-3}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: vltmt-0} - {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: vltmt-0}
- {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: vltmt-1} - {os: ubuntu-24.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: vltmt-1}
# Ubuntu 24.04 Clang - has problems # Ubuntu 24.04 Clang
- {os: ubuntu-24.04, compiler: {cc: clang, cxx: clang++}, reloc: 0, suite: dist-vlt-0}
- {os: ubuntu-24.04, compiler: {cc: clang, cxx: clang++}, reloc: 0, suite: dist-vlt-1}
- {os: ubuntu-24.04, compiler: {cc: clang, cxx: clang++}, reloc: 0, suite: dist-vlt-2}
- {os: ubuntu-24.04, compiler: {cc: clang, cxx: clang++}, reloc: 0, suite: dist-vlt-3}
- {os: ubuntu-24.04, compiler: {cc: clang, cxx: clang++}, reloc: 0, suite: vltmt-0}
- {os: ubuntu-24.04, compiler: {cc: clang, cxx: clang++}, reloc: 0, suite: vltmt-1}
# Ubuntu 22.04 GCC # Ubuntu 22.04 GCC
- {os: ubuntu-22.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: dist-vlt-0} - {os: ubuntu-22.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: dist-vlt-0}
- {os: ubuntu-22.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: dist-vlt-1} - {os: ubuntu-22.04, compiler: {cc: gcc, cxx: g++}, reloc: 0, suite: dist-vlt-1}

View File

@ -23,6 +23,8 @@ import time
from functools import lru_cache # Eventually use python 3.9's cache from functools import lru_cache # Eventually use python 3.9's cache
from pprint import pformat, pprint from pprint import pformat, pprint
import distro
if False: # pylint: disable=using-constant-test if False: # pylint: disable=using-constant-test
pprint(pformat("Ignored")) # Prevent unused warning pprint(pformat("Ignored")) # Prevent unused warning
@ -140,10 +142,10 @@ class Capabilities:
@staticproperty @staticproperty
def cxx_version() -> str: # pylint: disable=no-method-argument def cxx_version() -> str: # pylint: disable=no-method-argument
if Capabilities._cached_cxx_version is None: if Capabilities._cached_cxx_version is None:
Capabilities._cached_cxx_version = VtOs.run_capture(os.environ['MAKE'] + " -C " + Capabilities._cached_cxx_version = VtOs.run_capture(
os.environ['TEST_REGRESS'] + os.environ['MAKE'] + " --silent -C " + os.environ['TEST_REGRESS'] +
" -f Makefile print-cxx-version", " -f Makefile print-cxx-version",
check=False) check=False)
return Capabilities._cached_cxx_version return Capabilities._cached_cxx_version
@ -449,7 +451,7 @@ class Runner:
else: else:
error_msg = test.errors if test.errors else test.errors_keep_going error_msg = test.errors if test.errors else test.errors_keep_going
test.oprint("FAILED: " + error_msg) test.oprint("FAILED: " + error_msg)
makecmd = VtOs.getenv_def('VERILATOR_MAKE', os.environ['MAKE'] + "&&") makecmd = VtOs.getenv_def('VERILATOR_MAKE', os.environ['MAKE'] + " &&")
upperdir = 'test_regress/' if re.search(r'test_regress', os.getcwd()) else '' upperdir = 'test_regress/' if re.search(r'test_regress', os.getcwd()) else ''
self.fail_msgs.append("\t#" + test.soprint("%Error: " + error_msg) + "\t\t" + makecmd + self.fail_msgs.append("\t#" + test.soprint("%Error: " + error_msg) + "\t\t" + makecmd +
" " + upperdir + test.py_filename + ' ' + " " + upperdir + test.py_filename + ' ' +
@ -1238,6 +1240,13 @@ class VlTest:
self.skip("Test requires Coroutines; ignore error since not available\n") self.skip("Test requires Coroutines; ignore error since not available\n")
return return
if self.timing and self.sc and re.search(r'Ubuntu 24.04', distro.name(
pretty=True)) and re.search(r'clang', self.cxx_version):
self.skip(
"Test requires SystemC and Coroutines; broken on Ubuntu 24.04 w/clang\n" +
" OS=" + distro.name(pretty=True) + " CXX=" + self.cxx_version)
return
if param['verilator_make_cmake'] and not self.have_cmake: if param['verilator_make_cmake'] and not self.have_cmake:
self.skip( self.skip(
"Test requires CMake; ignore error since not available or version too old\n") "Test requires CMake; ignore error since not available or version too old\n")

View File

@ -17,6 +17,9 @@ if not test.have_coroutines:
if not test.have_cmake: if not test.have_cmake:
test.skip("cmake is not installed") test.skip("cmake is not installed")
if re.search(r'clang', test.cxx_version):
test.skip("Known clang bug on ubuntu-24.04")
test.compile(verilator_flags2=["--timescale 10ns/1ns --main --timing"], test.compile(verilator_flags2=["--timescale 10ns/1ns --main --timing"],
verilator_make_gmake=False, verilator_make_gmake=False,
verilator_make_cmake=True) verilator_make_cmake=True)

View File

@ -27,6 +27,7 @@
#endif #endif
#include <cassert>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
@ -207,7 +208,9 @@ void _arr_iter_check(const char* name, int wordSize, const int* lows) {
void _arr_access_format_check(TestVpiHandle& reg_h, int wordSize, const int* lows, void _arr_access_format_check(TestVpiHandle& reg_h, int wordSize, const int* lows,
const char* octVal_s, PLI_INT32 format) { const char* octVal_s, PLI_INT32 format) {
constexpr int MAX_SPANSIZE = 1024;
const int spanSize = wordSize / 2; const int spanSize = wordSize / 2;
assert(spanSize <= MAX_SPANSIZE);
s_vpi_value value_in; s_vpi_value value_in;
s_vpi_value value_out; s_vpi_value value_out;
s_vpi_error_info e; s_vpi_error_info e;
@ -226,14 +229,14 @@ void _arr_access_format_check(TestVpiHandle& reg_h, int wordSize, const int* low
TestVpiHandle subreg_h = vpi_handle_by_index(reg_h, lows[2] + i); TestVpiHandle subreg_h = vpi_handle_by_index(reg_h, lows[2] + i);
TEST_CHECK_NZ(subreg_h); TEST_CHECK_NZ(subreg_h);
char octSpan_s[spanSize / 3 + 1]; char octSpan_s[MAX_SPANSIZE / 3 + 1];
strncpy(octSpan_s, &octVal_s[spanSize / 3 * (1 - i)], spanSize / 3); strncpy(octSpan_s, &octVal_s[spanSize / 3 * (1 - i)], spanSize / 3);
octSpan_s[spanSize / 3] = '\0'; octSpan_s[spanSize / 3] = '\0';
uint64_t intVal; uint64_t intVal;
t_vpi_vecval vecVal[2]; t_vpi_vecval vecVal[2];
sscanf(octSpan_s, "%" SCNo64, &intVal); sscanf(octSpan_s, "%" SCNo64, &intVal);
char strVal_s[spanSize + 1]; // max length of the string happens for binary char strVal_s[MAX_SPANSIZE + 1]; // max length of the string happens for binary
if (format == vpiIntVal) { if (format == vpiIntVal) {
value_in.value.integer = intVal; value_in.value.integer = intVal;
@ -257,7 +260,7 @@ void _arr_access_format_check(TestVpiHandle& reg_h, int wordSize, const int* low
sprintf(strVal_s, "%0*" PRIx64, (spanSize + 3) / 4, intVal); sprintf(strVal_s, "%0*" PRIx64, (spanSize + 3) / 4, intVal);
value_in.value.str = strVal_s; value_in.value.str = strVal_s;
} else if (format == vpiOctStrVal) { } else if (format == vpiOctStrVal) {
sprintf(strVal_s, "%" PRIo64, intVal); sprintf(strVal_s, "%0*" PRIo64, (spanSize + 2) / 3, intVal);
value_in.value.str = strVal_s; value_in.value.str = strVal_s;
} else if (format == vpiStringVal) { } else if (format == vpiStringVal) {
const int byteCount = (spanSize + 7) / 8; const int byteCount = (spanSize + 7) / 8;
@ -305,17 +308,13 @@ void _arr_access_check(const char* name, int wordSize, const int* lows) {
std::uniform_int_distribution<uint64_t> rand64(std::numeric_limits<uint64_t>::min(), std::uniform_int_distribution<uint64_t> rand64(std::numeric_limits<uint64_t>::min(),
std::numeric_limits<uint64_t>::max()); std::numeric_limits<uint64_t>::max());
char octVal_s[wordSize / 3 + 1]; constexpr int MAX_WORDSIZE = 128;
assert(wordSize <= MAX_WORDSIZE);
char octVal_s[MAX_WORDSIZE / 3 + 2];
// fill octVal_s with random octal digits octVal_s[0] = '0' + (rand64(rng) % (1ULL << ((((wordSize - 1) % 3) + 1))));
if (wordSize < 64) { for (int i = 1; i < (wordSize + 2) / 3; ++i) octVal_s[i] = '0' + (rand64(rng) % 8);
sprintf(octVal_s, "%0*" PRIo64, wordSize / 3, octVal_s[(wordSize + 2) / 3] = '\0';
rand64(rng) % (static_cast<uint64_t>(1) << wordSize));
} else {
sprintf(octVal_s, "%0*" PRIo64, 63 / 3, rand64(rng));
sprintf(octVal_s + 63 / 3, "%0*" PRIo64, (wordSize - 63) / 3,
rand64(rng) % (static_cast<uint64_t>(1) << (wordSize - 63)));
}
// Assume that reading/writing to the "flattened" packed register is already tested, // Assume that reading/writing to the "flattened" packed register is already tested,
// check only reading/writing to sub-regs and validate the flattened result. // check only reading/writing to sub-regs and validate the flattened result.