-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a smoke test for usb mass storage
Assuming a single usb mass storage device is connected to the machine, randomly create a small file, write it to the device, remount it and compare MD5 sums.
- Loading branch information
1 parent
d5c02bf
commit 798dde4
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# SUSE's openQA tests | ||
# | ||
# Copyright SUSE LLC | ||
# SPDX-License-Identifier: FSFAP | ||
|
||
# Package: usb_nic | ||
# Summary: Simple smoke test for testing USB NIC connected to system | ||
# Maintainer: LSG QE Kernel <[email protected]> | ||
|
||
use base 'opensusebasetest'; | ||
use strict; | ||
use warnings; | ||
use testapi; | ||
use serial_terminal 'select_serial_terminal'; | ||
use utils; | ||
use Utils::Logging 'export_logs_basic'; | ||
|
||
sub run { | ||
my ($self) = @_; | ||
|
||
select_serial_terminal; | ||
|
||
my $lun = script_output 'lsscsi -t -v | grep usb | awk -F" " \'{split($2,a,/[\/]/); print a[6]}\''; | ||
my $device = "/dev/" . script_output "lsscsi -v | grep -m1 $lun | awk -F\"/\" \'{print \$3}\'"; | ||
|
||
|
||
# create filesystem, mountpoint and temporary file | ||
my $tmp = script_output 'mktemp -d'; | ||
my $file = "$tmp/file"; | ||
my $md5 = "$tmp/md5"; | ||
my $mountpoint = "$tmp/mount"; | ||
my $file_copy = "$mountpoint/file"; | ||
|
||
assert_script_run "mkdir $mountpoint"; | ||
assert_script_run "mkfs.btrfs -f $device"; | ||
|
||
assert_script_run "mount -t btrfs $device $mountpoint"; | ||
assert_script_run "dd if=/dev/urandom of=$file bs=1M count=16"; | ||
assert_script_run "md5sum $file > $md5"; | ||
assert_script_run "cp $file $file_copy"; | ||
|
||
# sync, unmount and flush slab and page cache | ||
assert_script_run 'sync'; | ||
assert_script_run "umount $mountpoint"; | ||
assert_script_run "echo 3 > /proc/sys/vm/drop_caches"; | ||
|
||
# remount and check md5sum | ||
assert_script_run "mount -t btrfs $device $mountpoint"; | ||
assert_script_run "cd $mountpoint; md5sum -c $md5; cd /"; | ||
|
||
# cleanup | ||
assert_script_run("umount $mountpoint"); | ||
assert_script_run("rm -r $tmp"); | ||
} | ||
|
||
sub test_flags { | ||
return {fatal => 0}; | ||
} | ||
|
||
1; |