aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBruce Lai <bruce.lai@sifive.com>2023-05-02 00:20:02 -0700
committerlibyuv LUCI CQ <libyuv-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-04 03:26:25 +0000
commit8811ad8ba13e8fc15cf68feb9529832962515cc2 (patch)
treec59db1d1a4c76ffa3221d4b82e9ae61151713ea9 /source
parent5c36ff76f1ce6550294c9c8b7777ffce15473b76 (diff)
downloadlibyuv-8811ad8ba13e8fc15cf68feb9529832962515cc2.tar.gz
Fix TestLinuxRVV test fail
Fail log: [ RUN ] LibYUVBaseTest.TestLinuxRVV Note: testing to load "../../unit_test/testdata/riscv64.txt" /scratch/brucel/libyuv/src/unit_test/cpu_test.cc:290: Failure Expected equality of these values: kCpuHasRVV | kCpuHasRVVZVFH Which is: 1610612736 RiscvCpuCaps("../../unit_test/testdata/riscv64_rvv_zvfh.txt") Which is: 536870912 [ FAILED ] LibYUVBaseTest.TestLinuxRVV (17 ms) Reason: The root cause is "\n" may be contained in the ext variable. The last of extension substring contains "\n". For instance, test case riscv64_rvv_zvfh.txt, the last substring is "zvfh\n" instead of "zvfh". Solved this failure by removing "\n" which is at the end of line. NOTE: We avoid using strstr() to solve the problem here. Becasue using strstr() will violate the parsing rule, if future extension contains "zvfh"(e.g zvfhxxx). Log after modification: [ RUN ] LibYUVBaseTest.TestLinuxRVV Note: testing to load "../../unit_test/testdata/riscv64.txt" [ OK ] LibYUVBaseTest.TestLinuxRVV (38 ms) Change-Id: I7b7db98dbc5388cbc148423da6892b8f0be64599 Signed-off-by: Bruce Lai <bruce.lai@sifive.com> Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/4498101 Reviewed-by: Frank Barchard <fbarchard@chromium.org> Commit-Queue: Frank Barchard <fbarchard@chromium.org>
Diffstat (limited to 'source')
-rw-r--r--source/cpu_id.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/source/cpu_id.cc b/source/cpu_id.cc
index 61de60f3..0c4a1581 100644
--- a/source/cpu_id.cc
+++ b/source/cpu_id.cc
@@ -181,26 +181,31 @@ LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) {
// ISA string must begin with rv64{i,e,g} for a 64-bit processor.
char* isa = strstr(cpuinfo_line, "rv64");
if (isa) {
- const int isa_len = strlen(isa);
- // 5 ISA characters + 1 new-line character
- if (isa_len < 6) {
+ size_t isa_len = strlen(isa);
+ char* extensions;
+ size_t extensions_len = 0;
+ size_t std_isa_len;
+ // Remove the new-line character at the end of string
+ if (isa[isa_len - 1] == '\n') {
+ isa[--isa_len] = '\0';
+ }
+ // 5 ISA characters
+ if (isa_len < 5) {
fclose(f);
return 0;
}
// Skip {i,e,g} canonical checking.
// Skip rvxxx
isa += 5;
-
// Find the very first occurrence of 's', 'x' or 'z'.
// To detect multi-letter standard, non-standard, and
// supervisor-level extensions.
- int extensions_len = 0;
- char* extensions = strpbrk(isa, "zxs");
+ extensions = strpbrk(isa, "zxs");
if (extensions) {
- extensions_len = strlen(extensions);
// Multi-letter extensions are seperated by a single underscore
// as described in RISC-V User-Level ISA V2.2.
char* ext = strtok(extensions, "_");
+ extensions_len = strlen(extensions);
while (ext) {
// Search for the ZVFH (Vector FP16) extension.
if (!strcmp(ext, "zvfh")) {
@@ -209,7 +214,7 @@ LIBYUV_API SAFEBUFFERS int RiscvCpuCaps(const char* cpuinfo_name) {
ext = strtok(NULL, "_");
}
}
- const int std_isa_len = isa_len - extensions_len - 5 - 1;
+ std_isa_len = isa_len - extensions_len - 5;
// Detect the v in the standard single-letter extensions.
if (memchr(isa, 'v', std_isa_len)) {
// The RVV implied the F extension.