mirror of git://gcc.gnu.org/git/gcc.git
selftest.c: avoid explicit "selftest::" qualifiers
gcc/ChangeLog:
* selftest.c: Move "namespace selftest {" to top of file,
removing explicit "selftest::" qualifiers throughout.
From-SVN: r239892
This commit is contained in:
parent
c6b0037d0e
commit
96f14006f5
|
|
@ -1,3 +1,8 @@
|
||||||
|
2016-08-31 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
* selftest.c: Move "namespace selftest {" to top of file,
|
||||||
|
removing explicit "selftest::" qualifiers throughout.
|
||||||
|
|
||||||
2016-08-31 Marc Glisse <marc.glisse@inria.fr>
|
2016-08-31 Marc Glisse <marc.glisse@inria.fr>
|
||||||
|
|
||||||
* config/i386/avx512fintrin.h (__m512_u, __m512i_u, __m512d_u):
|
* config/i386/avx512fintrin.h (__m512_u, __m512i_u, __m512d_u):
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,14 @@ along with GCC; see the file COPYING3. If not see
|
||||||
|
|
||||||
#if CHECKING_P
|
#if CHECKING_P
|
||||||
|
|
||||||
int selftest::num_passes;
|
namespace selftest {
|
||||||
|
|
||||||
|
int num_passes;
|
||||||
|
|
||||||
/* Record the successful outcome of some aspect of a test. */
|
/* Record the successful outcome of some aspect of a test. */
|
||||||
|
|
||||||
void
|
void
|
||||||
selftest::pass (const location &/*loc*/, const char */*msg*/)
|
pass (const location &/*loc*/, const char */*msg*/)
|
||||||
{
|
{
|
||||||
num_passes++;
|
num_passes++;
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +39,7 @@ selftest::pass (const location &/*loc*/, const char */*msg*/)
|
||||||
/* Report the failed outcome of some aspect of a test and abort. */
|
/* Report the failed outcome of some aspect of a test and abort. */
|
||||||
|
|
||||||
void
|
void
|
||||||
selftest::fail (const location &loc, const char *msg)
|
fail (const location &loc, const char *msg)
|
||||||
{
|
{
|
||||||
fprintf (stderr,"%s:%i: %s: FAIL: %s\n", loc.m_file, loc.m_line,
|
fprintf (stderr,"%s:%i: %s: FAIL: %s\n", loc.m_file, loc.m_line,
|
||||||
loc.m_function, msg);
|
loc.m_function, msg);
|
||||||
|
|
@ -47,7 +49,7 @@ selftest::fail (const location &loc, const char *msg)
|
||||||
/* As "fail", but using printf-style formatted output. */
|
/* As "fail", but using printf-style formatted output. */
|
||||||
|
|
||||||
void
|
void
|
||||||
selftest::fail_formatted (const location &loc, const char *fmt, ...)
|
fail_formatted (const location &loc, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
|
@ -65,26 +67,23 @@ selftest::fail_formatted (const location &loc, const char *fmt, ...)
|
||||||
to be non-NULL; fail gracefully if either are NULL. */
|
to be non-NULL; fail gracefully if either are NULL. */
|
||||||
|
|
||||||
void
|
void
|
||||||
selftest::assert_streq (const location &loc,
|
assert_streq (const location &loc,
|
||||||
const char *desc_expected, const char *desc_actual,
|
const char *desc_expected, const char *desc_actual,
|
||||||
const char *val_expected, const char *val_actual)
|
const char *val_expected, const char *val_actual)
|
||||||
{
|
{
|
||||||
/* If val_expected is NULL, the test is buggy. Fail gracefully. */
|
/* If val_expected is NULL, the test is buggy. Fail gracefully. */
|
||||||
if (val_expected == NULL)
|
if (val_expected == NULL)
|
||||||
::selftest::fail_formatted
|
fail_formatted (loc, "ASSERT_STREQ (%s, %s) expected=NULL",
|
||||||
(loc, "ASSERT_STREQ (%s, %s) expected=NULL",
|
desc_expected, desc_actual);
|
||||||
desc_expected, desc_actual);
|
|
||||||
/* If val_actual is NULL, fail with a custom error message. */
|
/* If val_actual is NULL, fail with a custom error message. */
|
||||||
if (val_actual == NULL)
|
if (val_actual == NULL)
|
||||||
::selftest::fail_formatted
|
fail_formatted (loc, "ASSERT_STREQ (%s, %s) expected=\"%s\" actual=NULL",
|
||||||
(loc, "ASSERT_STREQ (%s, %s) expected=\"%s\" actual=NULL",
|
desc_expected, desc_actual, val_expected);
|
||||||
desc_expected, desc_actual, val_expected);
|
|
||||||
if (0 == strcmp (val_expected, val_actual))
|
if (0 == strcmp (val_expected, val_actual))
|
||||||
::selftest::pass (loc, "ASSERT_STREQ");
|
pass (loc, "ASSERT_STREQ");
|
||||||
else
|
else
|
||||||
::selftest::fail_formatted
|
fail_formatted (loc, "ASSERT_STREQ (%s, %s) expected=\"%s\" actual=\"%s\"",
|
||||||
(loc, "ASSERT_STREQ (%s, %s) expected=\"%s\" actual=\"%s\"",
|
desc_expected, desc_actual, val_expected, val_actual);
|
||||||
desc_expected, desc_actual, val_expected, val_actual);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Implementation detail of ASSERT_STR_CONTAINS.
|
/* Implementation detail of ASSERT_STR_CONTAINS.
|
||||||
|
|
@ -93,36 +92,35 @@ selftest::assert_streq (const location &loc,
|
||||||
::selftest::fail if it is not found. */
|
::selftest::fail if it is not found. */
|
||||||
|
|
||||||
void
|
void
|
||||||
selftest::assert_str_contains (const location &loc,
|
assert_str_contains (const location &loc,
|
||||||
const char *desc_haystack,
|
const char *desc_haystack,
|
||||||
const char *desc_needle,
|
const char *desc_needle,
|
||||||
const char *val_haystack,
|
const char *val_haystack,
|
||||||
const char *val_needle)
|
const char *val_needle)
|
||||||
{
|
{
|
||||||
/* If val_haystack is NULL, fail with a custom error message. */
|
/* If val_haystack is NULL, fail with a custom error message. */
|
||||||
if (val_haystack == NULL)
|
if (val_haystack == NULL)
|
||||||
::selftest::fail_formatted
|
fail_formatted (loc, "ASSERT_STR_CONTAINS (%s, %s) haystack=NULL",
|
||||||
(loc, "ASSERT_STR_CONTAINS (%s, %s) haystack=NULL",
|
desc_haystack, desc_needle);
|
||||||
desc_haystack, desc_needle);
|
|
||||||
|
|
||||||
/* If val_needle is NULL, fail with a custom error message. */
|
/* If val_needle is NULL, fail with a custom error message. */
|
||||||
if (val_needle == NULL)
|
if (val_needle == NULL)
|
||||||
::selftest::fail_formatted
|
fail_formatted (loc,
|
||||||
(loc, "ASSERT_STR_CONTAINS (%s, %s) haystack=\"%s\" needle=NULL",
|
"ASSERT_STR_CONTAINS (%s, %s) haystack=\"%s\" needle=NULL",
|
||||||
desc_haystack, desc_needle, val_haystack);
|
desc_haystack, desc_needle, val_haystack);
|
||||||
|
|
||||||
const char *test = strstr (val_haystack, val_needle);
|
const char *test = strstr (val_haystack, val_needle);
|
||||||
if (test)
|
if (test)
|
||||||
::selftest::pass (loc, "ASSERT_STR_CONTAINS");
|
pass (loc, "ASSERT_STR_CONTAINS");
|
||||||
else
|
else
|
||||||
::selftest::fail_formatted
|
fail_formatted
|
||||||
(loc, "ASSERT_STR_CONTAINS (%s, %s) haystack=\"%s\" needle=\"%s\"",
|
(loc, "ASSERT_STR_CONTAINS (%s, %s) haystack=\"%s\" needle=\"%s\"",
|
||||||
desc_haystack, desc_needle, val_haystack, val_needle);
|
desc_haystack, desc_needle, val_haystack, val_needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Constructor. Generate a name for the file. */
|
/* Constructor. Generate a name for the file. */
|
||||||
|
|
||||||
selftest::named_temp_file::named_temp_file (const char *suffix)
|
named_temp_file::named_temp_file (const char *suffix)
|
||||||
{
|
{
|
||||||
m_filename = make_temp_file (suffix);
|
m_filename = make_temp_file (suffix);
|
||||||
ASSERT_NE (m_filename, NULL);
|
ASSERT_NE (m_filename, NULL);
|
||||||
|
|
@ -130,7 +128,7 @@ selftest::named_temp_file::named_temp_file (const char *suffix)
|
||||||
|
|
||||||
/* Destructor. Delete the tempfile. */
|
/* Destructor. Delete the tempfile. */
|
||||||
|
|
||||||
selftest::named_temp_file::~named_temp_file ()
|
named_temp_file::~named_temp_file ()
|
||||||
{
|
{
|
||||||
unlink (m_filename);
|
unlink (m_filename);
|
||||||
diagnostics_file_cache_forcibly_evict_file (m_filename);
|
diagnostics_file_cache_forcibly_evict_file (m_filename);
|
||||||
|
|
@ -141,23 +139,20 @@ selftest::named_temp_file::~named_temp_file ()
|
||||||
it. Abort if anything goes wrong, using LOC as the effective
|
it. Abort if anything goes wrong, using LOC as the effective
|
||||||
location in the problem report. */
|
location in the problem report. */
|
||||||
|
|
||||||
selftest::temp_source_file::temp_source_file (const location &loc,
|
temp_source_file::temp_source_file (const location &loc,
|
||||||
const char *suffix,
|
const char *suffix,
|
||||||
const char *content)
|
const char *content)
|
||||||
: named_temp_file (suffix)
|
: named_temp_file (suffix)
|
||||||
{
|
{
|
||||||
FILE *out = fopen (get_filename (), "w");
|
FILE *out = fopen (get_filename (), "w");
|
||||||
if (!out)
|
if (!out)
|
||||||
::selftest::fail_formatted (loc, "unable to open tempfile: %s",
|
fail_formatted (loc, "unable to open tempfile: %s", get_filename ());
|
||||||
get_filename ());
|
|
||||||
fprintf (out, "%s", content);
|
fprintf (out, "%s", content);
|
||||||
fclose (out);
|
fclose (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Selftests for the selftest system itself. */
|
/* Selftests for the selftest system itself. */
|
||||||
|
|
||||||
namespace selftest {
|
|
||||||
|
|
||||||
/* Sanity-check the ASSERT_ macros with various passing cases. */
|
/* Sanity-check the ASSERT_ macros with various passing cases. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -181,9 +176,8 @@ test_named_temp_file ()
|
||||||
named_temp_file t (".txt");
|
named_temp_file t (".txt");
|
||||||
FILE *f = fopen (t.get_filename (), "w");
|
FILE *f = fopen (t.get_filename (), "w");
|
||||||
if (!f)
|
if (!f)
|
||||||
selftest::fail_formatted (SELFTEST_LOCATION,
|
fail_formatted (SELFTEST_LOCATION,
|
||||||
"unable to open %s for writing",
|
"unable to open %s for writing", t.get_filename ());
|
||||||
t.get_filename ());
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue