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