summaryrefslogtreecommitdiff
path: root/gcc/input.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-13 21:04:07 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-06-13 21:04:07 +0000
commitd0982399db40ba5bac6bf53bea44b8bdd49e136a (patch)
treea7dc6a7feb0754dac0ba89c788d492dc8864951a /gcc/input.c
parent12cb83674cdc58e3cdfbf741a31af4e6091825ac (diff)
downloadgcc-d0982399db40ba5bac6bf53bea44b8bdd49e136a.tar.gz
selftests: improve reported failure locations
This patch introduce a selftest::location struct to wrap up __FILE__ and __LINE__ information (and __FUNCTION__) throughout the selftests, allowing location information to be passed around. It updates the helper functions in pretty-print.c to pass through the precise location of each test, so that if a failure occurs, the correct line number is printed, rather than a line within a helper function. gcc/ChangeLog: * input.c (test_reading_source_line): Use SELFTEST_LOCATION. * pretty-print.c (assert_pp_format_va): Add location param and use it with ASSERT_STREQ_AT. (assert_pp_format): Add location param and pass it to assert_pp_format_va. (assert_pp_format_colored): Likewise. (ASSERT_PP_FORMAT_1): New. (ASSERT_PP_FORMAT_2): New. (ASSERT_PP_FORMAT_3): New. (test_pp_format): Provide SELFTEST_LOCATION throughout, either explicitly, or implicitly via the above macros. * selftest.c (selftest::pass): Use a selftest::location rather than file and line. (selftest::fail): Likewise. Print the function name. (selftest::fail_formatted): Likewise. (selftest::assert_streq): Use a selftest::location rather than file and line. * selftest.h (selftest::location): New struct. (SELFTEST_LOCATION): New macro. (selftest::pass): Accept a const location & rather than file and line. (selftest::fail): Likewise. (selftest::fail_formatted): Likewise. (selftest::assert_streq): Likewise. (ASSERT_TRUE): Update for above changes, using SELFTEST_LOCATION. (ASSERT_FALSE): Likewise. (ASSERT_EQ): Likewise. (ASSERT_NE): Likewise. (ASSERT_STREQ): Likewise. (ASSERT_PRED1): Likewise. (ASSERT_STREQ_AT): New macro. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@237410 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/input.c')
-rw-r--r--gcc/input.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/input.c b/gcc/input.c
index e872cf039f7..1d004f8cd73 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -1231,10 +1231,10 @@ test_reading_source_line ()
ASSERT_EQ (53, line_size);
if (!strncmp (" The quick brown fox jumps over the lazy dog. */",
source_line, line_size))
- ::selftest::pass (__FILE__, __LINE__,
+ ::selftest::pass (SELFTEST_LOCATION,
"source_line matched expected value");
else
- ::selftest::fail (__FILE__, __LINE__,
+ ::selftest::fail (SELFTEST_LOCATION,
"source_line did not match expected value");
}