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