Merge lp:~liuyq0307/lava-android-test/sdcard-mounted into lp:lava-android-test

Proposed by Yongqin Liu
Status: Superseded
Proposed branch: lp:~liuyq0307/lava-android-test/sdcard-mounted
Merge into: lp:lava-android-test
Diff against target: 94 lines (+69/-3)
2 files modified
lava_android_test/test_definitions/hostshells/example.sh (+4/-3)
lava_android_test/test_definitions/hostshells/sdcard-mounted.sh (+65/-0)
To merge this branch: bzr merge lp:~liuyq0307/lava-android-test/sdcard-mounted
Reviewer Review Type Date Requested Status
Linaro Validation Team Pending
Review via email: mp+123696@code.launchpad.net

This proposal has been superseded by a proposal from 2012-09-13.

Description of the change

add test for checking if the sdcard partition is mounted

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

50 + echo "Usage $0 [--serial|-s serial]"

I'd say this is confusing/incorrect as both options can consume optional argument.

In addition $0 is whatever was execed (which is fine) but it tends to be long (/usr/bin/foobar)

Revision history for this message
Andy Doan (doanac) wrote :

On 09/12/2012 07:13 AM, Zygmunt Krynicki wrote:
> In addition $0 is whatever was execed (which is fine) but it tends to be long (/usr/bin/foobar)

funny, I've always been a fan of $0 there because it can help debugging
odd things at times :) Hadn't thought of that perspective.

Revision history for this message
Antonio Terceiro (terceiro) wrote :

Zygmunt Krynicki escreveu:
> In addition $0 is whatever was execed (which is fine) but it tends to
> be long (/usr/bin/foobar)

I usually use $(basename $0) to avoid very long names.

207. By Yongqin Liu

use $(basename $0) instead of $0 in usage

Revision history for this message
Yongqin Liu (liuyq0307) wrote :

> 50 + echo "Usage $0 [--serial|-s serial]"
>
> I'd say this is confusing/incorrect as both options can consume optional
> argument.
sorry, why you say that's confusing/incorrect?
by that I just want to say that we support both follow commands:
  sdcard-mounted.sh --serial serial
  sdcard-mounted.sh --s serial

And I just borrow this code from lava-partition-disk in lp:lava-master-image-scripts,
did not see the difference between the usage of them.:(

> In addition $0 is whatever was execed (which is fine) but it tends to be long
> (/usr/bin/foobar)
changed to use $(basename $0)

Revision history for this message
Zygmunt Krynicki (zyga) wrote :

W dniu 13.09.2012 04:05, Yongqin Liu pisze:
>> 50 + echo "Usage $0 [--serial|-s serial]"
>>
>> I'd say this is confusing/incorrect as both options can consume optional
>> argument.
> sorry, why you say that's confusing/incorrect?
> by that I just want to say that we support both follow commands:
> sdcard-mounted.sh --serial serial
> sdcard-mounted.sh --s serial

The fact that they take an optional argument.

Sorry for making my previous argument confusing, I would just use
something like this instead:

Usage: sdcard-mounted.sh [OPTIONS]

Available options:

    -s [SERIAL] | --serial [SERIAL]
  The serial device to connect to.
  TODO: Describe what is the default value
  when --serial|-s is passed without an argument

>> In addition $0 is whatever was execed (which is fine) but it tends to be long
>> (/usr/bin/foobar)
> changed to use $(basename $0)

I second that, $(basename $0) is a simple solution

Thanks
ZK

208. By Yongqin Liu

update the usage style

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_android_test/test_definitions/hostshells/example.sh'
2--- lava_android_test/test_definitions/hostshells/example.sh 2012-07-10 06:34:06 +0000
3+++ lava_android_test/test_definitions/hostshells/example.sh 2012-09-13 08:47:18 +0000
4@@ -27,7 +27,8 @@
5 if [ -n "${SERIAL}" ]; then
6 shift 2
7 else
8- shift 1
9+ show_usage
10+ exit 1
11 fi
12 ;;
13 --help|-h)
14@@ -48,8 +49,8 @@
15
16 function show_usage(){
17 # Display the usage line
18- echo "Usage $0 [--serial|-s serial] other-option"
19- echo "Usage $0 [--help|-h]"
20+ echo "Usage $(basename $0) [--serial <serial>|-s <serial>] <other-option>"
21+ echo "Usage $(basename $0) [--help|-h]"
22 }
23
24 function main(){
25
26=== added file 'lava_android_test/test_definitions/hostshells/sdcard-mounted.sh'
27--- lava_android_test/test_definitions/hostshells/sdcard-mounted.sh 1970-01-01 00:00:00 +0000
28+++ lava_android_test/test_definitions/hostshells/sdcard-mounted.sh 2012-09-13 08:47:18 +0000
29@@ -0,0 +1,65 @@
30+#!/bin/bash
31+# Copyright (c) 2012 Linaro
32+
33+# Author: Linaro Validation Team <linaro-dev@lists.linaro.org>
34+#
35+# This file is part of LAVA Android Test.
36+#
37+# This program is free software: you can redistribute it and/or modify
38+# it under the terms of the GNU General Public License as published by
39+# the Free Software Foundation, either version 3 of the License, or
40+# (at your option) any later version.
41+#
42+# This program is distributed in the hope that it will be useful,
43+# but WITHOUT ANY WARRANTY; without even the implied warranty of
44+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45+# GNU General Public License for more details.
46+#
47+# You should have received a copy of the GNU General Public License
48+# along with this program. If not, see <http://www.gnu.org/licenses/>.
49+
50+function parse_argv() {
51+ # Parse command line arguments
52+ while test -n "$1"; do
53+ case "$1" in
54+ --serial|-s)
55+ SERIAL="$2"
56+ if [ -n "${SERIAL}" ]; then
57+ shift 2
58+ else
59+ show_usage
60+ exit 1
61+ fi
62+ ;;
63+ --help|-h)
64+ show_usage
65+ exit 1
66+ ;;
67+ *)
68+ shift
69+ ;;
70+ esac
71+ done
72+}
73+
74+function show_usage(){
75+ # Display the usage line
76+ echo "Usage $(basename $0) [--serial <serial>|-s <serial>]"
77+ echo "Usage $(basename $0) [--help|-h]"
78+}
79+
80+function main(){
81+ parse_argv "$@"
82+ ADB_OPTION=''
83+ if [ -n "${SERIAL}" ]; then
84+ ADB_OPTION="-s ${SERIAL}"
85+ fi
86+ adb ${ADB_OPTION} shell mount |grep 'sdcard '
87+ if [ $? -eq 0 ]; then
88+ echo "sdcard-mounted=pass"
89+ else
90+ echo "sdcard-mounted=fail"
91+ fi
92+}
93+
94+main "$@"

Subscribers

People subscribed via source and target branches