blob: 2461e20d500e188b1327cadaf75142b2c32a30a3 [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"
39[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
40mkdir -p "${OUTPUT}"
41
42info_msg "About to run MMC test..."
43info_msg "Output directory: ${OUTPUT}"
44
45# Check kernel config
46if [ -f /proc/config.gz ]
47then
48 CONFIG_MMC=$(zcat /proc/config.gz | grep "CONFIG_MMC=")
49 CONFIG_MMC_SDHCI=$(zcat /proc/config.gz | grep "CONFIG_MMC_SDHCI=")
50elif [ -f /boot/config-"$(uname -r)" ]
51then
52 KERNEL_CONFIG_FILE="/boot/config-$(uname -r)"
53 CONFIG_MMC=$(grep "CONFIG_MMC=" "${KERNEL_CONFIG_FILE}")
54 CONFIG_MMC_SDHCI=$(grep "CONFIG_MMC_SDHCI=" "${KERNEL_CONFIG_FILE}")
55else
56 exit_on_skip "mmc-pre-requirements" "Kernel config file not available"
57fi
58
59( [ "${CONFIG_MMC}" = "CONFIG_MMC=y" ] || [ "${CONFIG_MMC}" = "CONFIG_MMC=m" ] ) && ( [ "${CONFIG_MMC_SDHCI}" = "CONFIG_MMC_SDHCI=y" ] || [ "${CONFIG_MMC_SDHCI}" = "CONFIG_MMC_SDHCI=m" ] )
60exit_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"
61
62list_all_mmc_devices