Files
binutils-gdb/libsframe/testsuite/sframe-test.h
Indu Bhagat 4dc07bf60c libsframe: testsuite: make test names unique
Fix PR libsframe/33437 - libsframe test names are not unique

The TEST () macro definition originally in plt-findfre-2.c, was being
used to differentiate between multiple runs of the testcases.  Adapt
that definition a bit to allow for a variable number of arguments following
the test condition: A test name format string may be used by macro
users, such that the name of the tests are unique.

Move the new variadic TEST macro definition in the testsuite's common
header sframe-test.h, and use it throughout the testsuite.

Reviewed-by: Jens Remus <jremus@linux.ibm.com>

libsframe/testsuite/
	PR libsframe/33437
	* libsframe.decode/be-flipping.c: Use new TEST macro with
	suffix.
	* libsframe.decode/frecnt-1.c: Likewise.
	* libsframe.decode/frecnt-2.c: Likewise.
	* libsframe.encode/encode-1.c: Likewise.
	* libsframe.find/findfre-1.c: Likewise.
	* libsframe.find/findfunc-1.c: Likewise.
	* libsframe.find/plt-findfre-1.c: Likewise.
	* libsframe.find/plt-findfre-2.c: Likewise.
	* sframe-test.h: Move the TEST macro definition to this
	testsuite header.
2025-10-02 15:26:10 -07:00

54 lines
1.5 KiB
C

/* sframe-test.h -- Common libsframe testsuite header.
Copyright (C) 2022-2025 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _SFRAME_TEST_H
#define _SFRAME_TEST_H
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "sframe-api.h"
/* DejaGnu should not use gnulib's vsnprintf replacement here. */
#undef vsnprintf
/* PR 33168: Solaris <sys/wait.h> with __EXTENSIONS__ defined gets a
declaration of wait(). This conflicts with <dejagnu.h>'s wait
definition that is only removed after DejaGnu 1.6.3. */
#define wait dg_wait
/* Add prototype to avoid warning. */
void wait (void);
#include <dejagnu.h>
#undef wait
#define TEST(cond, subname, ...) \
do \
{ \
if (cond) \
pass (subname, ##__VA_ARGS__); \
else \
fail (subname, ##__VA_ARGS__); \
} \
while (0)
#endif /* _SFRAME_TEST_H */