Skip to content

Commit 2a6b6c9

Browse files
masahir0yshuahkh
authored andcommitted
selftests: harness: remove unneeded __constructor_order_last()
__constructor_order_last() is unneeded. If __constructor_order_last() is not called on backward-order systems, __constructor_order will remain 0 instead of being set to _CONSTRUCTOR_ORDER_BACKWARD (= -1). __LIST_APPEND() will still take the 'else' branch, so there is no difference in the behavior. Signed-off-by: Masahiro Yamada <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent f0a1ffa commit 2a6b6c9

File tree

4 files changed

+1
-28
lines changed

4 files changed

+1
-28
lines changed

tools/testing/selftests/drivers/s390x/uvdevice/test_uvdevice.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,6 @@ TEST_F(attest_fixture, att_inval_addr)
257257
att_inval_addr_test(&self->uvio_attest.meas_addr, _metadata, self);
258258
}
259259

260-
static void __attribute__((constructor)) __constructor_order_last(void)
261-
{
262-
if (!__constructor_order)
263-
__constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
264-
}
265-
266260
int main(int argc, char **argv)
267261
{
268262
int fd = open(UV_PATH, O_ACCMODE);

tools/testing/selftests/hid/hid_bpf.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,12 +1331,6 @@ static int libbpf_print_fn(enum libbpf_print_level level,
13311331
return 0;
13321332
}
13331333

1334-
static void __attribute__((constructor)) __constructor_order_last(void)
1335-
{
1336-
if (!__constructor_order)
1337-
__constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
1338-
}
1339-
13401334
int main(int argc, char **argv)
13411335
{
13421336
/* Use libbpf 1.0 API mode */

tools/testing/selftests/kselftest_harness.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,6 @@
488488
* Use once to append a main() to the test file.
489489
*/
490490
#define TEST_HARNESS_MAIN \
491-
static void __attribute__((constructor)) \
492-
__constructor_order_last(void) \
493-
{ \
494-
if (!__constructor_order) \
495-
__constructor_order = _CONSTRUCTOR_ORDER_BACKWARD; \
496-
} \
497491
int main(int argc, char **argv) { \
498492
return test_harness_run(argc, argv); \
499493
}
@@ -891,7 +885,6 @@ static struct __fixture_metadata *__fixture_list = &_fixture_global;
891885
static int __constructor_order;
892886

893887
#define _CONSTRUCTOR_ORDER_FORWARD 1
894-
#define _CONSTRUCTOR_ORDER_BACKWARD -1
895888

896889
static inline void __register_fixture(struct __fixture_metadata *f)
897890
{
@@ -1337,8 +1330,7 @@ static int test_harness_run(int argc, char **argv)
13371330

13381331
static void __attribute__((constructor)) __constructor_order_first(void)
13391332
{
1340-
if (!__constructor_order)
1341-
__constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
1333+
__constructor_order = _CONSTRUCTOR_ORDER_FORWARD;
13421334
}
13431335

13441336
#endif /* __KSELFTEST_HARNESS_H */

tools/testing/selftests/rtc/rtctest.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,6 @@ TEST_F_TIMEOUT(rtc, alarm_wkalm_set_minute, 65) {
410410
ASSERT_EQ(new, secs);
411411
}
412412

413-
static void __attribute__((constructor))
414-
__constructor_order_last(void)
415-
{
416-
if (!__constructor_order)
417-
__constructor_order = _CONSTRUCTOR_ORDER_BACKWARD;
418-
}
419-
420413
int main(int argc, char **argv)
421414
{
422415
switch (argc) {

0 commit comments

Comments
 (0)