test: prove package initialization semantics
This commit is contained in:
36
test/sep/limitexec.c
Normal file
36
test/sep/limitexec.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/resource.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Test-only deterministic launcher for allocation-failure observers. Keeping
|
||||
* setrlimit in a repository-built helper avoids depending on util-linux paths
|
||||
* or shell-specific ulimit syntax. */
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 3) {
|
||||
fputs("usage: sep-limitexec bytes program [arg ...]\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
errno = 0;
|
||||
char *end = NULL;
|
||||
unsigned long long value = strtoull(argv[1], &end, 10);
|
||||
if (errno != 0 || end == argv[1] || *end != '\0') {
|
||||
fputs("sep-limitexec: invalid limit\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
struct rlimit limit;
|
||||
limit.rlim_cur = (rlim_t)value;
|
||||
limit.rlim_max = (rlim_t)value;
|
||||
if (setrlimit(RLIMIT_AS, &limit) != 0) {
|
||||
fputs("sep-limitexec: setrlimit failed\n", stderr);
|
||||
return 2;
|
||||
}
|
||||
execv(argv[2], &argv[2]);
|
||||
fputs("sep-limitexec: exec failed\n", stderr);
|
||||
return 127;
|
||||
}
|
||||
1421
test/sep/sepinit_test.ww
Normal file
1421
test/sep/sepinit_test.ww
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user