xref: /spdk/test/event/scheduler/scheduler.sh (revision 3d2a3ee4dfe82b9581161ac67eec7f60a33dc62d)
1#!/usr/bin/env bash
2
3testdir=$(readlink -f $(dirname $0))
4rootdir=$(readlink -f $testdir/../../..)
5source $rootdir/test/common/autotest_common.sh
6
7function scheduler_create_thread() {
8	$rpc --plugin scheduler_plugin scheduler_thread_create -n active_pinned -m 0x1 -a 100
9	$rpc --plugin scheduler_plugin scheduler_thread_create -n active_pinned -m 0x2 -a 100
10	$rpc --plugin scheduler_plugin scheduler_thread_create -n active_pinned -m 0x4 -a 100
11	$rpc --plugin scheduler_plugin scheduler_thread_create -n active_pinned -m 0x8 -a 100
12	$rpc --plugin scheduler_plugin scheduler_thread_create -n idle_pinned -m 0x1 -a 0
13	$rpc --plugin scheduler_plugin scheduler_thread_create -n idle_pinned -m 0x2 -a 0
14	$rpc --plugin scheduler_plugin scheduler_thread_create -n idle_pinned -m 0x4 -a 0
15	$rpc --plugin scheduler_plugin scheduler_thread_create -n idle_pinned -m 0x8 -a 0
16
17	$rpc --plugin scheduler_plugin scheduler_thread_create -n one_third_active -a 30
18	thread_id=$($rpc --plugin scheduler_plugin scheduler_thread_create -n half_active -a 0)
19	$rpc --plugin scheduler_plugin scheduler_thread_set_active $thread_id 50
20
21	thread_id=$($rpc --plugin scheduler_plugin scheduler_thread_create -n deleted -a 100)
22	$rpc --plugin scheduler_plugin scheduler_thread_delete $thread_id
23}
24
25rpc=rpc_cmd
26
27# Use -f to enable spdk_for_each_reactor regression test for #2206.
28# This results in constant event processing even on reactors without any SPDK threads.
29# The utilization of reactors might differ from expected.
30$testdir/scheduler -m 0xF -p 0x2 --wait-for-rpc -f &
31scheduler_pid=$!
32trap 'killprocess $scheduler_pid; exit 1' SIGINT SIGTERM EXIT
33waitforlisten $scheduler_pid
34
35$rpc framework_set_scheduler dynamic
36$rpc framework_start_init
37
38# basic integrity test
39run_test "scheduler_create_thread" scheduler_create_thread
40
41trap - SIGINT SIGTERM EXIT
42killprocess $scheduler_pid
43