summaryrefslogtreecommitdiffstats
path: root/tests/squelch_scsi_id/main.sh
blob: 33943031e43348cab0bafe760a81ca2ebcf5ba4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash

# Copyright (c) 2016 Red Hat, Inc. 
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Author: Lin Li   <lilin@redhat.com>

source ../include/ec.sh || exit 200

function main (){
    local exit_status=1

    Multipath_installation || Fail "fail to install device-mapper-multipath"
    Print_kernel_info
    Print_multipath_pkginfo
    
    local stdout stderr

    Log "create the multipathed disk via scsi_debug"
    _init || Fail "fail to create the multipathed disk"
    Cmd "multipath -ll"
    Log "fail the multipathed disk"
    Cmd "echo 0 > /sys/bus/pseudo/drivers/scsi_debug/max_luns"
    Log "check the output of multipath  & multipath -ll $mpath"
#will print the unexpected output if the issue is still there
#multipath to scan disks
    Cmd "multipath ; multipath -ll $mpath" 
    stdout=${_STDOUT}
    stderr=${_STDERR}
#mark as pass if no scsi_id error message observered
    echo $stdout $stderr | grep '/lib/udev/scsi_id exitted' 1>/dev/null || exit_status=0 
    Cmd "echo 2 > /sys/bus/pseudo/drivers/scsi_debug/max_luns"
    Cmd "multipath ; multipath -ll $mpath" 
    _destroy  

    return $exit_status
}

main || Fail "still print the message: scsi_id exitted while scanning the failed path"

Pass