[rhel6-branch 07/10] Add test script for loadkeys-stub

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Related: rhbz#706099
---
 command-stubs/loadkeys-test |   54 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 command-stubs/loadkeys-test

diff --git a/command-stubs/loadkeys-test b/command-stubs/loadkeys-test
new file mode 100644
index 0000000..dda718d
--- /dev/null
+++ b/command-stubs/loadkeys-test
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+#
+# loadkeys-test
+#
+# Copyright (C) 2011  Red Hat, Inc.  All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from subprocess import call, check_call, CalledProcessError
+import sys
+
+
+def loadkeys_test():
+    # existing keymap
+    rc = call(['loadkeys', 'us'])
+    if not rc == 0:
+        print('loadkeys: load existing keymap test failed')
+        sys.exit(1)
+
+    # non-existing keymap
+    rc = call(['loadkeys', 'bad-keymap'])
+    if rc == 0:
+        print('loadkeys: load non-existing keymap test failed')
+        sys.exit(1)
+
+def wrong_usage_test():
+    try:
+        # missing all arguments
+        check_call(['loadkeys'])
+        # extra arguments
+        check_call(['loadkeys', 'us', 'extra'])
+    except CalledProcessError:
+        # this is OK
+        pass
+    else:
+        print('loadkeys: wrong usage test failed')
+        sys.exit(1)
+
+
+if __name__ == '__main__':
+    loadkeys_test()
+    wrong_usage_test()
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux