forked from OSchip/llvm-project
[demangler] improve test harness
The demangler test harness is a little unclear. The failed demangling message always causes me to think about 'reality', changing to a simple 'Found' seems clearer. The expected-to-fail tests abort as soon as one passes, rather than continue, and then abort if any passed. This changes that loop to fail at the end, in a similar manner to the expected-to-work loop. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D118130
This commit is contained in:
parent
b58174d624
commit
52c7faeae8
|
@ -29946,51 +29946,43 @@ void test()
|
||||||
for (unsigned i = 0; i < N; ++i)
|
for (unsigned i = 0; i < N; ++i)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
char* demang = __cxxabiv1::__cxa_demangle(cases[i][0], buf, &len, &status);
|
char* demang =
|
||||||
if (demang == 0 || std::strcmp(demang, cases[i][1]) != 0)
|
__cxxabiv1::__cxa_demangle(cases[i][0], buf, &len, &status);
|
||||||
|
if (!demang || std::strcmp(demang, cases[i][1]) != 0)
|
||||||
{
|
{
|
||||||
std::printf("ERROR demangling %s\nexpected: %s\n", cases[i][0], cases[i][1]);
|
std::printf("ERROR demangling %s\nexpected: %s\n",
|
||||||
if (demang)
|
cases[i][0], cases[i][1]);
|
||||||
{
|
std::printf("Got: %d, %s\n", status, demang ? demang : "(null)");
|
||||||
std::printf(" reality: %s\n", demang);
|
failed = true;
|
||||||
buf = demang;
|
|
||||||
failed = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::printf("Got instead: NULL, %d\n", status);
|
|
||||||
failed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buf = demang;
|
|
||||||
}
|
}
|
||||||
|
if (demang)
|
||||||
|
buf = demang;
|
||||||
}
|
}
|
||||||
assert(!failed);
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
assert(!failed && "demangle failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_invalid_cases()
|
void test_invalid_cases()
|
||||||
{
|
{
|
||||||
std::size_t len = 0;
|
std::size_t len = 0;
|
||||||
char* buf = nullptr;
|
char* buf = nullptr;
|
||||||
|
bool passed = false;
|
||||||
for (unsigned i = 0; i < NI; ++i)
|
for (unsigned i = 0; i < NI; ++i)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
char* demang = __cxxabiv1::__cxa_demangle(invalid_cases[i], buf, &len, &status);
|
char* demang =
|
||||||
|
__cxxabiv1::__cxa_demangle(invalid_cases[i], buf, &len, &status);
|
||||||
if (status != -2)
|
if (status != -2)
|
||||||
{
|
{
|
||||||
std::printf("%s should be invalid but is not\n", invalid_cases[i]);
|
std::printf("%s should be invalid but is not\n", invalid_cases[i]);
|
||||||
std::printf("Got status %d\n", status);
|
std::printf("Got: %d, %s\n", status, demang ? demang : "(null)");
|
||||||
assert(status == -2);
|
passed = true;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
buf = demang;
|
|
||||||
}
|
}
|
||||||
|
if (demang)
|
||||||
|
buf = demang;
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
|
assert(!passed && "demangle did not fail");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *xfail_cases[] = {
|
const char *xfail_cases[] = {
|
||||||
|
|
Loading…
Reference in New Issue