FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 06-01-2011, 01:18 PM
Martin Gracik
 
Default Add test script for mknod-stub

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

diff --git a/command-stubs/mknod-test b/command-stubs/mknod-test
new file mode 100644
index 0000000..abff629
--- /dev/null
+++ b/command-stubs/mknod-test
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+#
+# mknod-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/>.
+#
+
+import os
+from subprocess import call, check_call, CalledProcessError
+import sys
+
+
+def create_device_test(device, type, major, minor):
+ # new device
+ rc = call(['mknod', device, type, major, minor])
+ if not rc == 0:
+ print('mknod: create new device test failed')
+ sys.exit(1)
+
+ try:
+ os.stat(device)
+ except OSError:
+ print('mknod: create new device test failed')
+ sys.exit(1)
+
+ # existing device
+ fail = False
+ rc = call(['mknod', device, type, major, minor])
+ if rc == 0:
+ print('mknod: create existing device test failed')
+ fail = True
+
+ # cleanup
+ os.unlink(device)
+
+ if fail:
+ sys.exit(1)
+
+def wrong_device_type_test():
+ rc = call(['mknod', '/dev/test-wrong', 'x', '1', '1'])
+ if rc == 0:
+ print('mknod: wrong device type test failed')
+ sys.exit(1)
+
+def wrong_usage_test():
+ try:
+ # missing all arguments
+ check_call(['mknod'])
+ # missing major, minor
+ check_call(['mknod', '/dev/test-wrong', 'b'])
+ check_call(['mknod', '/dev/test-wrong', 'c'])
+ # extra arguments
+ check_call(['mknod', '/dev/test', 'c', '1', '1', 'extra'])
+ except CalledProcessError:
+ # this is OK
+ pass
+ else:
+ print('mknod: wrong usage test failed')
+ sys.exit(1)
+
+def help_test():
+ rc = call(['mknod', '--help'])
+ if not rc == 0:
+ print('mknod: help test failed')
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ create_device_test('/dev/test-block', 'b', '1', '1')
+ create_device_test('/dev/test-char', 'c', '1', '1')
+ wrong_device_type_test()
+ wrong_usage_test()
+ help_test()
--
1.7.3.2

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

Thread Tools




All times are GMT. The time now is 04:06 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org