mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
selftests/mm: hugetlb-shm: use kselftest framework
Convert hugetlb-shm test to use kselftest framework for reporting and tracking successful and failing runs. Link: https://lore.kernel.org/20260511162840.375890-9-rppt@kernel.org Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Donet Tom <donettom@linux.ibm.com> Reviewed-by: Mark Brown <broonie@kernel.org> Tested-by: Sarthak Sharma <sarthak.sharma@arm.com> Tested-by: Luiz Capitulino <luizcap@redhat.com> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: John Hubbard <jhubbard@nvidia.com> Cc: Lance Yang <lance.yang@linux.dev> Cc: Leon Romanovsky <leon@kernel.org> Cc: Liam Howlett <liam@infradead.org> Cc: Li Wang <li.wang@linux.dev> Cc: Lorenzo Stoakes <ljs@kernel.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Nico Pache <npache@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Ryan Roberts <ryan.roberts@arm.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Vlastimil Babka <vbabka@kernel.org> Cc: Zi Yan <ziy@nvidia.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
a93cbee527
commit
f62c93fa8b
|
|
@ -28,9 +28,9 @@
|
|||
#include <sys/shm.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#define LENGTH (256UL*1024*1024)
|
||||
#include "vm_util.h"
|
||||
|
||||
#define dprintf(x) printf(x)
|
||||
#define LENGTH (256UL*1024*1024)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
|
|
@ -38,44 +38,41 @@ int main(void)
|
|||
unsigned long i;
|
||||
char *shmaddr;
|
||||
|
||||
ksft_print_header();
|
||||
ksft_set_plan(1);
|
||||
|
||||
shmid = shmget(2, LENGTH, SHM_HUGETLB | IPC_CREAT | SHM_R | SHM_W);
|
||||
if (shmid < 0) {
|
||||
perror("shmget");
|
||||
exit(1);
|
||||
}
|
||||
printf("shmid: 0x%x\n", shmid);
|
||||
if (shmid < 0)
|
||||
ksft_exit_fail_perror("shmget");
|
||||
|
||||
ksft_print_msg("shmid: 0x%x\n", shmid);
|
||||
|
||||
shmaddr = shmat(shmid, NULL, 0);
|
||||
if (shmaddr == (char *)-1) {
|
||||
perror("Shared memory attach failure");
|
||||
ksft_perror("Shared memory attach failure");
|
||||
shmctl(shmid, IPC_RMID, NULL);
|
||||
exit(2);
|
||||
ksft_exit_fail();
|
||||
}
|
||||
printf("shmaddr: %p\n", shmaddr);
|
||||
ksft_print_msg("shmaddr: %p\n", shmaddr);
|
||||
|
||||
dprintf("Starting the writes:\n");
|
||||
for (i = 0; i < LENGTH; i++) {
|
||||
shmaddr[i] = (char)(i);
|
||||
if (!(i % (1024 * 1024)))
|
||||
dprintf(".");
|
||||
}
|
||||
dprintf("\n");
|
||||
|
||||
dprintf("Starting the Check...");
|
||||
ksft_print_msg("Starting the writes:\n");
|
||||
for (i = 0; i < LENGTH; i++)
|
||||
if (shmaddr[i] != (char)i) {
|
||||
printf("\nIndex %lu mismatched\n", i);
|
||||
exit(3);
|
||||
}
|
||||
dprintf("Done.\n");
|
||||
shmaddr[i] = (char)(i);
|
||||
|
||||
ksft_print_msg("Starting the Check...");
|
||||
for (i = 0; i < LENGTH; i++)
|
||||
if (shmaddr[i] != (char)i)
|
||||
ksft_exit_fail_msg("Data mismatch at index %lu\n", i);
|
||||
ksft_print_msg("Done.\n");
|
||||
|
||||
if (shmdt((const void *)shmaddr) != 0) {
|
||||
perror("Detach failure");
|
||||
ksft_perror("Detach failure");
|
||||
shmctl(shmid, IPC_RMID, NULL);
|
||||
exit(4);
|
||||
ksft_exit_fail();
|
||||
}
|
||||
|
||||
shmctl(shmid, IPC_RMID, NULL);
|
||||
|
||||
return 0;
|
||||
ksft_test_result_pass("hugepage using SysV shmget/shmat\n");
|
||||
ksft_finished();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user