blob: 341f94170f70aee2d10d4ebf7b082f2d251b42d2 [file] [log] [blame]
Naresh Kambojuc3a32af2017-01-18 11:16:22 +05301#!/bin/sh
2#
3# MMC test cases
4#
5# Copyright (C) 2017, Linaro Limited.
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License
9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20#
21# Author: Naresh Kamboju <naresh.kamboju@linaro.org>
22#
23
24# shellcheck disable=SC1091
25. ../../lib/sh-test-lib
26OUTPUT="$(pwd)/output"
27RESULT_FILE="${OUTPUT}/result.txt"
28export RESULT_FILE
29
30# List the mmc devices
31list_all_mmc_devices() {
32 info_msg "Running list-all-mmc-devices test..."
33 lsblk | grep "mmc"
34 exit_on_fail "mmc"
35}
36
37# Test run.
38! check_root && error_msg "This script must be run as root"
Daniel Díaz6f49a1b2017-02-15 18:56:15 -060039create_out_dir "${OUTPUT}"
Naresh Kambojuc3a32af2017-01-18 11:16:22 +053040
41info_msg "About to run MMC test..."
42info_msg "Output directory: ${OUTPUT}"
43
44# Check kernel config
45if [ -f /proc/config.gz ]
46then
47 CONFIG_MMC=$(zcat /proc/config.gz | grep "CONFIG_MMC=")
48 CONFIG_MMC_SDHCI=$(zcat /proc/config.gz | grep "CONFIG_MMC_SDHCI=")
49elif [ -f /boot/config-"$(uname -r)" ]
50then
51 KERNEL_CONFIG_FILE="/boot/config-$(uname -r)"
52 CONFIG_MMC=$(grep "CONFIG_MMC=" "${KERNEL_CONFIG_FILE}")
53 CONFIG_MMC_SDHCI=$(grep "CONFIG_MMC_SDHCI=" "${KERNEL_CONFIG_FILE}")
54else
55 exit_on_skip "mmc-pre-requirements" "Kernel config file not available"
56fi
57
Milosz Wasilewski60152062020-03-02 18:53:29 +000058{ [ "${CONFIG_MMC}" = "CONFIG_MMC=y" ] || [ "${CONFIG_MMC}" = "CONFIG_MMC=m" ]; } && { [ "${CONFIG_MMC_SDHCI}" = "CONFIG_MMC_SDHCI=y" ] || [ "${CONFIG_MMC_SDHCI}" = "CONFIG_MMC_SDHCI=m" ]; }
Naresh Kambojuc3a32af2017-01-18 11:16:22 +053059exit_on_skip "mmc-pre-requirements" "Kernel config CONFIG_MMC=y or CONFIG_MMC=m and CONFIG_MMC_SDHCI=y or CONFIG_MMC_SDHCI=m not enabled"
60
61list_all_mmc_devices