1 /**
2 * no_limit_cross_test_execution.c
3 * DiagThresholdTest
4 *
5 * Simple test that checks if a process gets diagnostic memory
6 * threshold notifications when it does NOT cross the limit.
7 *
8 * Copyright (c) 2023 Apple Inc. All rights reserved.
9 */
10
11 #include <stdio.h>
12 #include "vm/diag_threshold_test.h"
13 #include <sys/kern_memorystatus.h>
14
15 static void no_limit_cross_test_execution(struct test_case *test_case, void *param);
16 T_GLOBAL_META(
17 T_META_ENABLED(TARGET_OS_IPHONE),
18 T_META_NAMESPACE("xnu.vm.100432442"),
19 T_META_RADAR_COMPONENT_NAME("xnu"),
20 T_META_OWNER("jsolsona"),
21 T_META_RADAR_COMPONENT_VERSION("VM")
22 );
23
24 static test_case_t diag_mem_threshold_no_limit_cross_test = {
25 .short_name = "no_limit_cross_test",
26 .test_name = "In this test is not expected to pass the threshold limit",
27 .test_code = no_limit_cross_test_execution,
28 .result_already_present = FALSE,
29 .exception_not_expected = TRUE,
30 };
31
32
33 static void
no_limit_cross_test_execution(__unused struct test_case * test_case,void * param)34 no_limit_cross_test_execution(__unused struct test_case *test_case, void *param)
35 {
36 test_context_t *info = (test_context_t *)param;
37 dispatch_semaphore_signal(info->executor_ready_for_exceptions);
38 (void)set_memory_diagnostics_threshold_limits(WORKING_LIMIT, true);
39 diag_mem_threshold_waste_memory(WORKING_LIMIT - (1024 * 1024));
40 }
41
42
43 T_DECL(diag_mem_threshold_no_limit_cross,
44 "In this test is not expected to pass the threshold limit")
45 {
46 diag_mem_threshold_set_setup(&diag_mem_threshold_no_limit_cross_test);
47 }
48