diff options
| author | Laura Peskin <pesk@google.com> | 2022-11-07 16:37:06 -0800 |
|---|---|---|
| committer | glpesk <114444708+glpesk@users.noreply.github.com> | 2022-11-15 11:29:31 -0800 |
| commit | 3a127a3157fd19caabb023978737471213127590 (patch) | |
| tree | 4052df0fc1f03ffb1b7f02a290ca88b864ad21d9 /sys/fuchsia | |
| parent | f3cab5934d105412ced7a190300e5fb58d4ff425 (diff) | |
sys/fuchsia: add test for job syscalls
This change also makes a couple of small updates to job.txt:
- Express the documented limit of 1 policy struct when using
the TIMER_SLACK option to set policy
- Include padding in policy struct definition
Diffstat (limited to 'sys/fuchsia')
| -rw-r--r-- | sys/fuchsia/job.txt | 4 | ||||
| -rw-r--r-- | sys/fuchsia/test/job | 46 |
2 files changed, 48 insertions, 2 deletions
diff --git a/sys/fuchsia/job.txt b/sys/fuchsia/job.txt index 29483840b..199a8d06a 100644 --- a/sys/fuchsia/job.txt +++ b/sys/fuchsia/job.txt @@ -12,7 +12,7 @@ zx_job_create(job zx_job, options const[0], out ptr[out, zx_job]) zx_job_set_policy$BASIC_V1(job_handle zx_job, options flags[job_policy_options], topic const[ZX_JOB_POL_BASIC_V1], policy ptr[in, array[zx_policy_basic_v1]], count len[policy]) zx_job_set_policy$BASIC_V2(job_handle zx_job, options flags[job_policy_options], topic const[ZX_JOB_POL_BASIC_V2], policy ptr[in, array[zx_policy_basic_v2]], count len[policy]) -zx_job_set_policy$TIMER_SLACK(job_handle zx_job, options flags[job_policy_options], topic const[ZX_JOB_POL_TIMER_SLACK], policy ptr[in, array[zx_policy_timer_slack]], count len[policy]) +zx_job_set_policy$TIMER_SLACK(job_handle zx_job, options flags[job_policy_options], topic const[ZX_JOB_POL_TIMER_SLACK], policy ptr[in, array[zx_policy_timer_slack, 1]], count len[policy]) zx_job_set_critical(job zx_job, options flags[job_critical_options], process zx_process) zx_policy_basic_v1 { @@ -30,7 +30,7 @@ zx_policy_timer_slack { min_slack int64 default_mode flags[zx_policy_timer_mode, int32] # not mentioned in `job.fidl` but present in `policy.h` -# padding1 array[int8, 4] + padding1 array[int8, 4] } job_policy_options = ZX_JOB_POL_RELATIVE, ZX_JOB_POL_ABSOLUTE diff --git a/sys/fuchsia/test/job b/sys/fuchsia/test/job new file mode 100644 index 000000000..8126ccefb --- /dev/null +++ b/sys/fuchsia/test/job @@ -0,0 +1,46 @@ +# Expect failure when creating a job from an invalid handle. + +zx_job_create(0x0, 0x0, &AUTO) # ZX_ERR_BAD_HANDLE + +# Create a valid job handle and several child jobs. + +r1 = syz_job_default() +zx_job_create(r1, 0x0, &AUTO=<r2=>0x0) +zx_job_create(r1, 0x0, &AUTO=<r3=>0x0) +zx_job_create(r1, 0x0, &AUTO=<r4=>0x0) + +# With policy format ZX_JOB_POL_BASIC_V1, set policy ZX_POL_ACTION_ALLOW for condition ZX_POL_NEW_ANY. + +zx_job_set_policy$BASIC_V1(r2, 0x0, 0x0, &AUTO=[{0x3, 0x0}], 0x1) + +# With policy format ZX_JOB_POL_TIMER_SLACK, set a min slack of 256ns with a default mode of ZX_TIMER_SLACK_CENTER. + +zx_job_set_policy$TIMER_SLACK(r4, 0x0, 0x1, &AUTO=[{0x100, 0x0, "00000000"}], 0x1) + +# With policy format ZX_JOB_POL_BASIC_V2, set policy ZX_POL_ACTION_DENY for condition ZX_POL_NEW_ANY with flag ZX_POLICY_OVERRIDE_DENY. + +zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x1, 0x1}], 0x1) + +# Setting the same policy again should succeed with either the ZX_JOB_POL_ABSOLUTE or ZX_JOB_POL_RELATIVE option. + +zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x1, 0x1}], 0x1) + +# Setting a conflicting policy with the ZX_JOB_POL_RELATIVE option should succeed. + +zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x0, 0x1}], 0x1) + +# Setting a conflicting policy with the ZX_JOB_POL_ABSOLUTE option should fail. + +zx_job_set_policy$BASIC_V2(r3, 0x1, 0x01000000, &AUTO=[{0x3, 0x0, 0x1}], 0x1) # ZX_ERR_ALREADY_EXISTS + +# Create a grandchild job. Expect failure when setting a previously allowed policy once a job has a child job. + +zx_job_create(r3, 0x0, &AUTO=<r5=>0x0) +zx_job_set_policy$BASIC_V2(r3, 0x0, 0x01000000, &AUTO=[{0x3, 0x1, 0x1}], 0x1) # ZX_ERR_BAD_STATE + +# Create a process and set it as critical for a job. +# TODO: when possible, create a non-self process and test that the parent job dies when the process handle is closed. + +r6 = syz_job_default() +r7 = syz_process_self() +zx_job_set_critical(r6, 0x0, r7) |
