From: Yun Lu Add a return-value regression to the task_work_fail object, which test_task_work already runs through RUN_TESTS(). Assert -ENOENT when scheduling task work through a deleted map value. Positive step codes distinguish fixture failures and the callback does not access the map element. Signed-off-by: Yun Lu --- .../selftests/bpf/progs/task_work_fail.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/task_work_fail.c b/tools/testing/selftests/bpf/progs/task_work_fail.c index bc56bda..7c118c4 100644 --- a/tools/testing/selftests/bpf/progs/task_work_fail.c +++ b/tools/testing/selftests/bpf/progs/task_work_fail.c @@ -2,6 +2,7 @@ /* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */ #include +#include #include #include #include @@ -94,3 +95,28 @@ int map_null(struct pt_regs *args) bpf_task_work_schedule_resume(task, &work->tw, NULL, process_work); return 0; } + +static int deleted_task_work_cb(struct bpf_map *map, void *key, void *value) +{ + return 0; +} + +SEC("syscall") +__retval(-ENOENT) +int schedule_deleted_task_work(void *ctx) +{ + struct elem empty = {}, *value; + int key = 0; + + if (bpf_map_update_elem(&hmap, &key, &empty, BPF_NOEXIST)) + return 1; + value = bpf_map_lookup_elem(&hmap, &key); + if (!value) { + bpf_map_delete_elem(&hmap, &key); + return 2; + } + if (bpf_map_delete_elem(&hmap, &key)) + return 3; + return bpf_task_work_schedule_signal(bpf_get_current_task_btf(), + &value->tw, &hmap, deleted_task_work_cb); +} -- 2.43.0