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