MCPcopy Create free account
hub / github.com/Niko1221/Strata / test_real

Function test_real

engine/src/split/tools/memlock_test.cpp:187–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void test_real() {
188 // the soft AND hard limit are lowered to 256 KiB: the soft limit cannot be raised, the real mlock refuses most of 10 MiB (a process with CAP_IPC_LOCK is not limited: then all locks)
189 const int rc = in_child([] {
190 struct rlimit lo { 256 * 1024, 256 * 1024 };
191 if (setrlimit(RLIMIT_MEMLOCK, &lo) != 0) return 90;
192 uint8_t* a = map_pages(2 * MiB, 5);
193 uint8_t* b = map_pages(8 * MiB, 6);
194 const uint64_t sa = sum(a, 2 * MiB), sb = sum(b, 8 * MiB);
195 auto parts = two_parts(a, 2 * MiB, b, 8 * MiB);
196 const LockEnv e = read_lock_env(10 * MiB);
197 LockOutcome o = lock_parts(parts, e); // must return, whatever the kernel says
198 const bool privileged = o.locked == o.want;
199 if (!privileged && o.locked > 256 * 1024 + 4096) return 91;
200 if (!privileged && lock_line(parts, o).empty()) return 92;
201 if (sum(a, 2 * MiB) != sa || sum(b, 8 * MiB) != sb) return 93;
202 return 0;
203 });
204 CHECK(rc == 0);
205}
206
207void test_raise() {
208 // soft 128 KiB, hard 64 MiB, need 10 MiB: the soft limit is raised (privileged or not) and the whole lock succeeds

Callers 1

mainFunction · 0.70

Calls 8

in_childFunction · 0.85
map_pagesFunction · 0.85
sumFunction · 0.85
two_partsFunction · 0.85
read_lock_envFunction · 0.85
lock_partsFunction · 0.85
lock_lineFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected