1*94d3b452SApple OSS Distributions #include <darwintest.h> 2*94d3b452SApple OSS Distributions #include <uuid/uuid.h> 3*94d3b452SApple OSS Distributions #include <System/sys/proc_uuid_policy.h> 4*94d3b452SApple OSS Distributions #include <stdint.h> 5*94d3b452SApple OSS Distributions 6*94d3b452SApple OSS Distributions T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true)); 7*94d3b452SApple OSS Distributions 8*94d3b452SApple OSS Distributions #define NUM_PROC_UUID_POLICY_FLAGS 4 9*94d3b452SApple OSS Distributions 10*94d3b452SApple OSS Distributions T_DECL(proc_uuid_policy_26567533, "Tests passing a NULL uuid in (uap->uuid).", T_META_LTEPHASE(LTE_POSTINIT)) 11*94d3b452SApple OSS Distributions { 12*94d3b452SApple OSS Distributions int i, ret; 13*94d3b452SApple OSS Distributions uuid_t null_uuid; 14*94d3b452SApple OSS Distributions memset(null_uuid, 0, sizeof(uuid_t)); 15*94d3b452SApple OSS Distributions 16*94d3b452SApple OSS Distributions uint32_t policy_flags[] = { 17*94d3b452SApple OSS Distributions PROC_UUID_POLICY_FLAGS_NONE, 18*94d3b452SApple OSS Distributions PROC_UUID_NO_CELLULAR, 19*94d3b452SApple OSS Distributions PROC_UUID_NECP_APP_POLICY, 20*94d3b452SApple OSS Distributions PROC_UUID_ALT_DYLD_POLICY 21*94d3b452SApple OSS Distributions }; 22*94d3b452SApple OSS Distributions 23*94d3b452SApple OSS Distributions for (i = 0; i < NUM_PROC_UUID_POLICY_FLAGS; i++) { 24*94d3b452SApple OSS Distributions T_LOG("Testing policy add with flag value 0x%x", policy_flags[i]); 25*94d3b452SApple OSS Distributions 26*94d3b452SApple OSS Distributions /* Since UUID is null, this call should fail with errno = EINVAL. */ 27*94d3b452SApple OSS Distributions ret = proc_uuid_policy(PROC_UUID_POLICY_OPERATION_ADD, null_uuid, sizeof(uuid_t), policy_flags[i]); 28*94d3b452SApple OSS Distributions 29*94d3b452SApple OSS Distributions T_ASSERT_TRUE(ret == -1, "proc_uuid_policy returned %d", ret); 30*94d3b452SApple OSS Distributions T_WITH_ERRNO; 31*94d3b452SApple OSS Distributions T_ASSERT_TRUE(errno = EINVAL, "errno is %d", errno); 32*94d3b452SApple OSS Distributions } 33*94d3b452SApple OSS Distributions 34*94d3b452SApple OSS Distributions for (i = 0; i < NUM_PROC_UUID_POLICY_FLAGS; i++) { 35*94d3b452SApple OSS Distributions T_LOG("Testing policy remove with flag value 0x%x", policy_flags[i]); 36*94d3b452SApple OSS Distributions 37*94d3b452SApple OSS Distributions /* Since UUID is null, this call should fail with errno = EINVAL. */ 38*94d3b452SApple OSS Distributions ret = proc_uuid_policy(PROC_UUID_POLICY_OPERATION_REMOVE, null_uuid, sizeof(uuid_t), policy_flags[i]); 39*94d3b452SApple OSS Distributions 40*94d3b452SApple OSS Distributions T_ASSERT_TRUE(ret == -1, "proc_uuid_policy returned %d", ret); 41*94d3b452SApple OSS Distributions T_WITH_ERRNO; 42*94d3b452SApple OSS Distributions T_ASSERT_TRUE(errno = EINVAL, "errno is %d", errno); 43*94d3b452SApple OSS Distributions } 44*94d3b452SApple OSS Distributions } 45