shufti/truffle tests: silence ubsan warning

The ubsan support in clang warned about us accessing idx-1 of an array here.
This commit is contained in:
Justin Viiret 2017-05-25 12:46:01 +10:00 committed by Matthew Barr
parent 4105dd4805
commit 1d041b12b7
2 changed files with 20 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2016, Intel Corporation * Copyright (c) 2015-2017, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -910,12 +910,13 @@ TEST(ReverseShufti, ExecNoMatch1) {
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi); int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
ASSERT_NE(-1, ret); ASSERT_NE(-1, ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char *t1 = t + 1;
size_t len = strlen(t1); size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i); const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)(t1 - 1), rv); ASSERT_EQ((const u8 *)t, rv);
} }
} }
@ -929,12 +930,13 @@ TEST(ReverseShufti, ExecNoMatch2) {
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi); int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
ASSERT_NE(-1, ret); ASSERT_NE(-1, ret);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char *t1 = t + 1;
size_t len = strlen(t1); size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i); const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)(t1 - 1), rv); ASSERT_EQ((const u8 *)t, rv);
} }
} }
@ -947,12 +949,13 @@ TEST(ReverseShufti, ExecNoMatch3) {
int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi); int ret = shuftiBuildMasks(chars, (u8 *)&lo, (u8 *)&hi);
ASSERT_NE(-1, ret); ASSERT_NE(-1, ret);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; char t[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
char *t1 = t + 1;
size_t len = strlen(t1); size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {
const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i); const u8 *rv = rshuftiExec(lo, hi, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)(t1 - 1), rv); ASSERT_EQ((const u8 *)t, rv);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015-2016, Intel Corporation * Copyright (c) 2015-2017, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -391,12 +391,13 @@ TEST(ReverseTruffle, ExecNoMatch1) {
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2); truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char *t1 = t + 1;
size_t len = strlen(t1); size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i); const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)(t1 - 1), rv); ASSERT_EQ((const u8 *)t, rv);
} }
} }
@ -410,12 +411,13 @@ TEST(ReverseTruffle, ExecNoMatch2) {
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2); truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
char t1[] = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"; char t[] = " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";
char *t1 = t + 1;
size_t len = strlen(t1); size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i); const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)(t1 - 1), rv); ASSERT_EQ((const u8 *)t, rv);
} }
} }
@ -427,12 +429,13 @@ TEST(ReverseTruffle, ExecNoMatch3) {
truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2); truffleBuildMasks(chars, (u8 *)&mask1, (u8 *)&mask2);
char t1[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; char t[] = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
char *t1 = t + 1;
size_t len = strlen(t1); size_t len = strlen(t1);
for (size_t i = 0; i < 16; i++) { for (size_t i = 0; i < 16; i++) {
const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i); const u8 *rv = rtruffleExec(mask1, mask2, (u8 *)t1, (u8 *)t1 + len - i);
ASSERT_EQ((const u8 *)(t1 - 1), rv); ASSERT_EQ((const u8 *)t, rv);
} }
} }