mirror of
https://github.com/torvalds/linux.git
synced 2026-04-25 10:02:31 -04:00
This follow-up patch completes centralization of kselftest.h and ksefltest_harness.h includes in remaining seltests files, replacing all relative paths with a non-relative paths using shared -I include path in lib.mk Tested with gcc-13.3 and clang-18.1, and cross-compiled successfully on riscv, arm64, x86_64 and powerpc arch. [reddybalavignesh9979@gmail.com: add selftests include path for kselftest.h] Link: https://lkml.kernel.org/r/20251017090201.317521-1-reddybalavignesh9979@gmail.com Link: https://lkml.kernel.org/r/20251016104409.68985-1-reddybalavignesh9979@gmail.com Signed-off-by: Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com> Suggested-by: Andrew Morton <akpm@linux-foundation.org> Link: https://lore.kernel.org/lkml/20250820143954.33d95635e504e94df01930d0@linux-foundation.org/ Reviewed-by: Wei Yang <richard.weiyang@gmail.com> Cc: David Hildenbrand <david@redhat.com> Cc: David S. Miller <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Günther Noack <gnoack@google.com> Cc: Jakub Kacinski <kuba@kernel.org> Cc: Liam Howlett <liam.howlett@oracle.com> Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Mickael Salaun <mic@digikod.net> Cc: Ming Lei <ming.lei@redhat.com> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Simon Horman <horms@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
84 lines
1.9 KiB
C
84 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/******************************************************************************
|
|
*
|
|
* Copyright FUJITSU LIMITED 2010
|
|
* Copyright KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
|
|
*
|
|
* DESCRIPTION
|
|
* Wait on uninitialized heap. It shold be zero and FUTEX_WAIT should
|
|
* return immediately. This test is intent to test zero page handling in
|
|
* futex.
|
|
*
|
|
* AUTHOR
|
|
* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
|
|
*
|
|
* HISTORY
|
|
* 2010-Jan-6: Initial version by KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
|
|
*
|
|
*****************************************************************************/
|
|
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/mman.h>
|
|
#include <syscall.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <linux/futex.h>
|
|
#include <libgen.h>
|
|
|
|
#include "futextest.h"
|
|
#include "kselftest_harness.h"
|
|
|
|
#define WAIT_US 5000000
|
|
|
|
static int child_blocked = 1;
|
|
static bool child_ret;
|
|
void *buf;
|
|
|
|
void *wait_thread(void *arg)
|
|
{
|
|
int res;
|
|
|
|
child_ret = true;
|
|
res = futex_wait(buf, 1, NULL, 0);
|
|
child_blocked = 0;
|
|
|
|
if (res != 0 && errno != EWOULDBLOCK) {
|
|
ksft_exit_fail_msg("futex failure\n");
|
|
child_ret = false;
|
|
}
|
|
pthread_exit(NULL);
|
|
}
|
|
|
|
TEST(futex_wait_uninitialized_heap)
|
|
{
|
|
long page_size;
|
|
pthread_t thr;
|
|
int ret;
|
|
|
|
page_size = sysconf(_SC_PAGESIZE);
|
|
|
|
buf = mmap(NULL, page_size, PROT_READ|PROT_WRITE,
|
|
MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
|
|
if (buf == (void *)-1)
|
|
ksft_exit_fail_msg("mmap\n");
|
|
|
|
ret = pthread_create(&thr, NULL, wait_thread, NULL);
|
|
if (ret)
|
|
ksft_exit_fail_msg("pthread_create\n");
|
|
|
|
ksft_print_dbg_msg("waiting %dus for child to return\n", WAIT_US);
|
|
usleep(WAIT_US);
|
|
|
|
if (child_blocked)
|
|
ksft_test_result_fail("child blocked in kernel\n");
|
|
|
|
if (!child_ret)
|
|
ksft_test_result_fail("child error\n");
|
|
}
|
|
|
|
TEST_HARNESS_MAIN
|