mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
support: Use support_record_failure consistently
This causes more test programs to link in the support_record_failure function, which triggers an early call to mmap from an ELF constructor, but this should not have side effects intefering with the functionality actually under test (unlike, say, a call to malloc).
This commit is contained in:
22
ChangeLog
22
ChangeLog
@ -1,3 +1,25 @@
|
|||||||
|
2016-12-31 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
* support/check.h (FAIL_RET, FAIL_EXIT, FAIL_EXIT1): Document that
|
||||||
|
test failures are recorded.
|
||||||
|
* support/check.c (support_print_failure_impl): Call
|
||||||
|
support_record_failure.
|
||||||
|
(support_exit_failure_impl): Call support_record_failure if status
|
||||||
|
indicates failure.
|
||||||
|
* support/delayed_exit.c (delayed_exit_thread): Use FAIL_EXIT1.
|
||||||
|
* support/xasprintf.c (xasprintf): Likewise.
|
||||||
|
* support/xfork.c (xfork): Likewise.
|
||||||
|
* support/xpthread_check_return.c (xpthread_check_return):
|
||||||
|
Likewise.
|
||||||
|
* support/xsocket.c (xsocket): Likeweise.
|
||||||
|
* support/xwaitpid.c (xwaitpid): Likewise.
|
||||||
|
* support/support_record_failure.c (struct test_failures): Adjust
|
||||||
|
to coding style.
|
||||||
|
* support/support_test_verify_impl.c (support_test_verify_impl):
|
||||||
|
Adjust error messages.
|
||||||
|
* support/tst-support_record_failure-2.sh (different_status):
|
||||||
|
Adjust error messages.
|
||||||
|
|
||||||
2016-12-31 Florian Weimer <fweimer@redhat.com>
|
2016-12-31 Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
* support/namespace.h: New file.
|
* support/namespace.h: New file.
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <support/test-driver.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_failure (const char *file, int line, const char *format, va_list ap)
|
print_failure (const char *file, int line, const char *format, va_list ap)
|
||||||
@ -34,6 +35,7 @@ int
|
|||||||
support_print_failure_impl (const char *file, int line,
|
support_print_failure_impl (const char *file, int line,
|
||||||
const char *format, ...)
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
|
support_record_failure ();
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
print_failure (file, line, format, ap);
|
print_failure (file, line, format, ap);
|
||||||
@ -45,6 +47,8 @@ void
|
|||||||
support_exit_failure_impl (int status, const char *file, int line,
|
support_exit_failure_impl (int status, const char *file, int line,
|
||||||
const char *format, ...)
|
const char *format, ...)
|
||||||
{
|
{
|
||||||
|
if (status != EXIT_SUCCESS && status != EXIT_UNSUPPORTED)
|
||||||
|
support_record_failure ();
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
print_failure (file, line, format, ap);
|
print_failure (file, line, format, ap);
|
||||||
|
@ -23,15 +23,19 @@
|
|||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
/* Print failure message to standard output and return 1. */
|
/* Record a test failure, print the failure message to standard output
|
||||||
|
and return 1. */
|
||||||
#define FAIL_RET(...) \
|
#define FAIL_RET(...) \
|
||||||
return support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__)
|
return support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
/* Print failure message and terminate the process with STATUS. */
|
/* Print the failure message and terminate the process with STATUS.
|
||||||
|
Record a the process as failed if STATUS is neither EXIT_SUCCESS
|
||||||
|
nor EXIT_UNSUPPORTED. */
|
||||||
#define FAIL_EXIT(status, ...) \
|
#define FAIL_EXIT(status, ...) \
|
||||||
support_exit_failure_impl (status, __FILE__, __LINE__, __VA_ARGS__)
|
support_exit_failure_impl (status, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
/* Print failure message and terminate with exit status 1. */
|
/* Record a test failure, print the failure message and terminate with
|
||||||
|
exit status 1. */
|
||||||
#define FAIL_EXIT1(...) \
|
#define FAIL_EXIT1(...) \
|
||||||
support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__)
|
support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <support/check.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
@ -31,10 +32,7 @@ delayed_exit_thread (void *seconds_as_ptr)
|
|||||||
struct timespec delay = { seconds, 0 };
|
struct timespec delay = { seconds, 0 };
|
||||||
struct timespec remaining = { 0 };
|
struct timespec remaining = { 0 };
|
||||||
if (nanosleep (&delay, &remaining) != 0)
|
if (nanosleep (&delay, &remaining) != 0)
|
||||||
{
|
FAIL_EXIT1 ("nanosleep: %m");
|
||||||
printf ("error: nanosleep: %m\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
/* Exit the process sucessfully. */
|
/* Exit the process sucessfully. */
|
||||||
exit (0);
|
exit (0);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
propagate to the parent process. */
|
propagate to the parent process. */
|
||||||
struct test_failures
|
struct test_failures
|
||||||
{
|
{
|
||||||
unsigned counter;
|
unsigned int counter;
|
||||||
unsigned failed;
|
unsigned int failed;
|
||||||
};
|
};
|
||||||
static struct test_failures *state;
|
static struct test_failures *state;
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ support_test_verify_impl (int status, const char *file, int line,
|
|||||||
const char *expr)
|
const char *expr)
|
||||||
{
|
{
|
||||||
support_record_failure ();
|
support_record_failure ();
|
||||||
printf ("FAIL %s:%d: not true: %s\n", file, line, expr);
|
printf ("error: %s:%d: not true: %s\n", file, line, expr);
|
||||||
if (status >= 0)
|
if (status >= 0)
|
||||||
exit (status);
|
exit (status);
|
||||||
|
|
||||||
|
@ -52,15 +52,15 @@ different_status () {
|
|||||||
run_test 1 "error: 1 test failures" $direct --status=1
|
run_test 1 "error: 1 test failures" $direct --status=1
|
||||||
run_test 2 "error: 1 test failures" $direct --status=2
|
run_test 2 "error: 1 test failures" $direct --status=2
|
||||||
run_test 1 "error: 1 test failures" $direct --status=77
|
run_test 1 "error: 1 test failures" $direct --status=77
|
||||||
run_test 2 "FAIL tst-support_record_failure.c:108: not true: false
|
run_test 2 "error: tst-support_record_failure.c:108: not true: false
|
||||||
error: 1 test failures" $direct --test-verify
|
error: 1 test failures" $direct --test-verify
|
||||||
}
|
}
|
||||||
|
|
||||||
different_status
|
different_status
|
||||||
different_status --direct
|
different_status --direct
|
||||||
|
|
||||||
run_test 1 "FAIL tst-support_record_failure.c:113: not true: false
|
run_test 1 "error: tst-support_record_failure.c:113: not true: false
|
||||||
error: 1 test failures" --test-verify-exit
|
error: 1 test failures" --test-verify-exit
|
||||||
# --direct does not print the summary error message if exit is called.
|
# --direct does not print the summary error message if exit is called.
|
||||||
run_test 1 "FAIL tst-support_record_failure.c:113: not true: false" \
|
run_test 1 "error: tst-support_record_failure.c:113: not true: false" \
|
||||||
--direct --test-verify-exit
|
--direct --test-verify-exit
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <support/check.h>
|
||||||
|
|
||||||
char *
|
char *
|
||||||
xasprintf (const char *format, ...)
|
xasprintf (const char *format, ...)
|
||||||
@ -29,10 +30,7 @@ xasprintf (const char *format, ...)
|
|||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
char *result;
|
char *result;
|
||||||
if (vasprintf (&result, format, ap) < 0)
|
if (vasprintf (&result, format, ap) < 0)
|
||||||
{
|
FAIL_EXIT1 ("asprintf: %m");
|
||||||
printf ("error: asprintf: %m\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,13 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <support/check.h>
|
||||||
|
|
||||||
pid_t
|
pid_t
|
||||||
xfork (void)
|
xfork (void)
|
||||||
{
|
{
|
||||||
pid_t result = fork ();
|
pid_t result = fork ();
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
FAIL_EXIT1 ("fork: %m");
|
||||||
printf ("error: fork: %m\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <support/check.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
xpthread_check_return (const char *function, int value)
|
xpthread_check_return (const char *function, int value)
|
||||||
@ -28,7 +29,6 @@ xpthread_check_return (const char *function, int value)
|
|||||||
if (value != 0)
|
if (value != 0)
|
||||||
{
|
{
|
||||||
errno = value;
|
errno = value;
|
||||||
printf ("error: %s: %m\n", function);
|
FAIL_EXIT1 ("%s: %m", function);
|
||||||
exit (1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,6 @@ xsocket (int domain, int type, int protocol)
|
|||||||
{
|
{
|
||||||
int fd = socket (domain, type, protocol);
|
int fd = socket (domain, type, protocol);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
FAIL_EXIT1 ("socket (%d, %d, %d): %m\n", domain, type, protocol);
|
||||||
support_record_failure ();
|
|
||||||
printf ("error: socket (%d, %d, %d): %m\n", domain, type, protocol);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <support/check.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -27,9 +28,6 @@ xwaitpid (int pid, int *status, int flags)
|
|||||||
{
|
{
|
||||||
pid_t result = waitpid (pid, status, flags);
|
pid_t result = waitpid (pid, status, flags);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
{
|
FAIL_EXIT1 ("waitpid: %m\n");
|
||||||
printf ("error: waitpid: %m\n");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user