xref: /spdk/test/interrupt/reap_unregistered_poller.sh (revision b02581a89058ebaebe03bd0e16e3b58adfe406c1)
1#!/usr/bin/env bash
2#  SPDX-License-Identifier: BSD-3-Clause
3#  Copyright (C) 2021 Intel Corporation
4#  All rights reserved.
5#
6testdir=$(readlink -f $(dirname $0))
7rootdir=$(readlink -f $testdir/../..)
8source $rootdir/test/common/autotest_common.sh
9source $testdir/interrupt_common.sh
10
11# This test script makes sure that unregistered pollers are
12# reaped correctly when the target is running in interrupt mode.
13
14export PYTHONPATH=$PYTHONPATH:$rootdir/examples/interrupt_tgt
15
16# Set reactors with intr_tgt in intr mode
17start_intr_tgt
18
19# Record names of native created pollers.
20app_thread=$(rpc_cmd thread_get_pollers | jq -r '.threads[0]')
21native_pollers=$(jq -r '.active_pollers[].name' <<< $app_thread)
22native_pollers+=" "
23native_pollers+=$(jq -r '.timed_pollers[].name' <<< $app_thread)
24
25# Create one aio_bdev.
26# During the creation, vbdev examine process will get bdev_aio create
27# pollers like bdev_aio_group_poll poller, and then unregister it.
28setup_bdev_aio
29
30# Wait for examine to finish, and then sleep a very short amount of
31# time to allow the unregistered pollers to get reaped next time
32# the spdk_threads are polled
33"$rpc_py" bdev_wait_for_examine
34sleep 0.1
35
36# Record names of remaining pollers.
37app_thread=$(rpc_cmd thread_get_pollers | jq -r '.threads[0]')
38remaining_pollers=$(jq -r '.active_pollers[].name' <<< $app_thread)
39remaining_pollers+=" "
40remaining_pollers+=$(jq -r '.timed_pollers[].name' <<< $app_thread)
41
42# Since bdev_aio created pollers were already unregistered, so
43# remaining_pollers should be same with native_pollers.
44[[ "$remaining_pollers" == "$native_pollers" ]]
45
46trap - SIGINT SIGTERM EXIT
47killprocess $intr_tgt_pid
48cleanup
49