From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RHYoQ-0006CN-NZ for garchives@archives.gentoo.org; Sat, 22 Oct 2011 10:28:23 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B479721C06F; Sat, 22 Oct 2011 10:28:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 73EEB21C06F for ; Sat, 22 Oct 2011 10:28:14 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9DF3D1B4002 for ; Sat, 22 Oct 2011 10:28:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 0079F80042 for ; Sat, 22 Oct 2011 10:28:13 +0000 (UTC) From: "Matthias Schwarzott" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Matthias Schwarzott" Message-ID: Subject: [gentoo-commits] proj/udev-gentoo-scripts:master commit in: test/ X-VCS-Repository: proj/udev-gentoo-scripts X-VCS-Files: test/test_mount.sh X-VCS-Directories: test/ X-VCS-Committer: zzam X-VCS-Committer-Name: Matthias Schwarzott X-VCS-Revision: f0815a8bb0ef45cf421cb9f266402732e5791b39 Date: Sat, 22 Oct 2011 10:28:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 61bf226ea7a9b63bb6eaf4919f623a01 commit: f0815a8bb0ef45cf421cb9f266402732e5791b39 Author: Matthias Schwarzott gentoo org> AuthorDate: Sat Oct 22 09:59:23 2011 +0000 Commit: Matthias Schwarzott gentoo org> CommitDate: Sat Oct 22 10:03:29 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/udev-gentoo-s= cripts.git;a=3Dcommit;h=3Df0815a8b test: Add tests for mounting /dev --- test/test_mount.sh | 156 ++++++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 156 insertions(+), 0 deletions(-) diff --git a/test/test_mount.sh b/test/test_mount.sh new file mode 100755 index 0000000..e2e7d1b --- /dev/null +++ b/test/test_mount.sh @@ -0,0 +1,156 @@ +#!/bin/sh + +oneTimeSetUp() +{ + sed -e "s#/proc/filesystems#${SHUNIT_TMPDIR}/proc-filesystems#" \ + -e "s#^.*/lib/udev/shell-compat-KV.sh##" \ + < ../init.d/udev \ + > "${SHUNIT_TMPDIR}"/udev.initd + cp "${SHUNIT_TMPDIR}"/udev.initd /tmp + . "${SHUNIT_TMPDIR}"/udev.initd +} + +set_mountinfo_result() +{ + MOUNTINFO_RESULT=3D$1 +} + +set_dev_is_mounted() +{ + set_mountinfo_result 0 +} + +set_fstabinfo_result() +{ + FSTABINFO_RESULT=3D$1 +} + +set_fstab_has_dev() +{ + set_fstabinfo_result 0 +} + +set_proc_filesystems() +{ + local fs + for fs; do + echo "$fs" + done > "${SHUNIT_TMPDIR}"/proc-filesystems +} + +setUp() +{ + RC_CMD=3Dstart + rm -f "$SHUNIT_TMPDIR"/*.actual + set_proc_filesystems tmpfs + set_mountinfo_result 1 + set_fstabinfo_result 1 +} + +check_kv() +{ + local input=3D"$1" actual=3D expected=3D"$2" + actual=3D$(KV_to_int "$input" 2>/dev/null) + assertEquals "$?" "0" + assertEquals "$expected" "$actual" +} + +expect_fail_kv() +{ + local input=3D"$1" actual=3D + actual=3D$(KV_to_int "$input" 2>&1) + assertEquals "$?" "1" + assertEquals "" "$actual" +} + +get_KV() +{ + echo 7 +} + +KV_to_int() +{ + echo 5 +} + +mount() +{ + echo "mount $@" >> "$SHUNIT_TMPDIR"/mount_call.actual +} + +fstabinfo() +{ + echo "fstabinfo $@" >> "$SHUNIT_TMPDIR"/fstabinfo_call.actual + return "${FSTABINFO_RESULT}" +} + +mountinfo() +{ + echo "mountinfo $@" >> "$SHUNIT_TMPDIR"/mountinfo.actual + return "${MOUNTINFO_RESULT}" +} + +einfo() +{ + echo "einfo $@" >> "$SHUNIT_TMPDIR"/einfo.actual +} + +ebegin() +{ +: +} + +eend() +{ +: +} + + +testMountAlreadyMounted() +{ + set_dev_is_mounted + + mount_dev_directory + + assertFalse "fstabinfo must not be called" "[ -e '"$SHUNIT_TMPDIR"/fsta= binfo_call.actual' ]" + assertFalse "mount must not be called" "[ -e '"$SHUNIT_TMPDIR"/mount_ca= ll.actual' ]" +} + +testMountUseFstab() +{ + set_fstab_has_dev + + mount_dev_directory + + assertTrue "fstabinfo must be called" "[ -e '"$SHUNIT_TMPDIR"/fstabinfo= _call.actual' ]" + assertFalse "mount must not be called" "[ -e '"$SHUNIT_TMPDIR"/mount_ca= ll.actual' ]" +} + +testMountExplicitTmpfs() +{ + mount_dev_directory + + assertTrue "fstabinfo must be called" "[ -e '"$SHUNIT_TMPDIR"/fstabinfo= _call.actual' ]" + assertTrue "mount must be called" "[ -e '"$SHUNIT_TMPDIR"/mount_call.ac= tual' ]" + grep -q -- '-t tmpfs ' "$SHUNIT_TMPDIR"/mount_call.actual + assertTrue "$?" + grep -q -- '-t devtmpfs ' "$SHUNIT_TMPDIR"/mount_call.actual + assertFalse "$?" +} + +testMountExplicitDevtmpfs() +{ + set_proc_filesystems tmpfs devtmpfs + + mount_dev_directory + + assertTrue "fstabinfo must be called" "[ -e '"$SHUNIT_TMPDIR"/fstabinfo= _call.actual' ]" + assertTrue "mount must be called" "[ -e '"$SHUNIT_TMPDIR"/mount_call.ac= tual' ]" + grep -q -- '-t tmpfs ' "$SHUNIT_TMPDIR"/mount_call.actual + assertFalse "$?" + grep -q -- '-t devtmpfs ' "$SHUNIT_TMPDIR"/mount_call.actual + assertTrue "$?" +} + +. ./shunit2 +