mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
selftests/exec: load_address: conform test to TAP format output
[ Upstream commit c4095067736b7ed50316a2bc7c9577941e87ad45 ] Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Link: https://lore.kernel.org/r/20240304155928.1818928-2-usama.anjum@collabora.com Signed-off-by: Kees Cook <keescook@chromium.org> Stable-dep-of: 11854fe263eb ("binfmt_elf: Move brk for static PIE even if ASLR disabled") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1707053766
commit
fea22a3e06
@@ -5,6 +5,7 @@
|
|||||||
#include <link.h>
|
#include <link.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "../kselftest.h"
|
||||||
|
|
||||||
struct Statistics {
|
struct Statistics {
|
||||||
unsigned long long load_address;
|
unsigned long long load_address;
|
||||||
@@ -41,28 +42,23 @@ int main(int argc, char **argv)
|
|||||||
unsigned long long misalign;
|
unsigned long long misalign;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = dl_iterate_phdr(ExtractStatistics, &extracted);
|
ksft_print_header();
|
||||||
if (ret != 1) {
|
ksft_set_plan(1);
|
||||||
fprintf(stderr, "FAILED\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extracted.alignment == 0) {
|
ret = dl_iterate_phdr(ExtractStatistics, &extracted);
|
||||||
fprintf(stderr, "No alignment found\n");
|
if (ret != 1)
|
||||||
return 1;
|
ksft_exit_fail_msg("FAILED: dl_iterate_phdr\n");
|
||||||
} else if (extracted.alignment & (extracted.alignment - 1)) {
|
|
||||||
fprintf(stderr, "Alignment is not a power of 2\n");
|
if (extracted.alignment == 0)
|
||||||
return 1;
|
ksft_exit_fail_msg("FAILED: No alignment found\n");
|
||||||
}
|
else if (extracted.alignment & (extracted.alignment - 1))
|
||||||
|
ksft_exit_fail_msg("FAILED: Alignment is not a power of 2\n");
|
||||||
|
|
||||||
misalign = extracted.load_address & (extracted.alignment - 1);
|
misalign = extracted.load_address & (extracted.alignment - 1);
|
||||||
if (misalign) {
|
if (misalign)
|
||||||
printf("alignment = %llu, load_address = %llu\n",
|
ksft_exit_fail_msg("FAILED: alignment = %llu, load_address = %llu\n",
|
||||||
extracted.alignment, extracted.load_address);
|
extracted.alignment, extracted.load_address);
|
||||||
fprintf(stderr, "FAILED\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "PASS\n");
|
ksft_test_result_pass("Completed\n");
|
||||||
return 0;
|
ksft_finished();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user