From b20ffd3bf90eb26c884cff2ad0f88dd92d5ff24b Mon Sep 17 00:00:00 2001 From: Liam Li Date: Mar 01 2010 05:58:37 +0000 Subject: updated user check,changed the order of running environment. --- diff --git a/tests/anaconda/dvd_install.py b/tests/anaconda/dvd_install.py index b47ac07..5bcd350 100755 --- a/tests/anaconda/dvd_install.py +++ b/tests/anaconda/dvd_install.py @@ -64,18 +64,19 @@ def get_basearch(): return arch def user_env_check(): + login_id = os.getuid() login_user = os.environ['LOGNAME'] - print "log in user is: %s" % login_user - if login_user != "root" : - print "ERROR: Can't be run as a normal user!!" - print "You may have to run 'su -' or log in gnome as root!!" - sys.exit(1) - else : + print "log in user uid is: %s, user name is: %s" % (login_id, login_user) + if login_id == 0 and login_user == "root" : gconf_val = gconf.client_get_default().get_bool('/desktop/gnome/interface/accessibility') print "accessibility support is: %s" % gconf_val if gconf_val != True: print "Setting accessibility to True..." gconf.client_get_default().set_bool('/desktop/gnome/interface/accessibility', True) + else : + print "ERROR: Can't be run as a normal user!!" + print "You may have to run 'su -' or log in gnome as root!!" + sys.exit(1) def package_check(package_name): rpm_state = False @@ -100,8 +101,8 @@ def input_text(str): def get_kickstart_file(ksfile): if os.path.exists(ksfile): + time.sleep(1) ksfile = os.path.split(ksfile)[1] - print "Creating disk to save local kickstart file....\n" kstype = 'local' else : ksfile = ksfile @@ -122,6 +123,7 @@ def set_disk(name, ksfile, kstype): def put_local_ks(ksfile): import guestfs + print "creating object..." g = guestfs.GuestFS() f = open("/var/lib/libvirt/images/ks.img", "w") f.truncate (500 * 1024 * 1024) @@ -312,10 +314,20 @@ def anaconda_package_installation(name, readtimeout = 10800): def error_complete(): print "\n== testing complete ==\n" - print "The error was detected above,test failed!" + print "The error was detected above,test failed,test result is fail!!" if __name__ == '__main__': user_env_check() + opt = parse_args() + if opt.image is None and opt.kickstart is None: + print "usage: ./dvd_install.py -n VMname -k KickstartFile -a Arch -i DVD_image" + print "For example:" + print "./dvd_install.py -k http://server/ks.cfg -a i386 -i DVD_image |tee test.log\n" + sys.exit(1) + sys_arch = get_basearch() + if not opt.arch == sys_arch: + print "The current system does not support your test image arch" + sys.exit(1) if not package_check('qemu-kvm'): print "KVM was not installed in system, you have to install virtualization first" print "more information,please see at:http://fedoraproject.org/wiki/Virtualization_Quick_Start" @@ -324,16 +336,6 @@ if __name__ == '__main__': sys.exit(1) if not package_check('dogtail'): sys.exit(1) - opt = parse_args() - sys_arch = get_basearch() - if not opt.arch == sys_arch: - print "The current system does not support your test image arch" - sys.exit(1) - if opt.image is None and opt.kickstart is None: - print "usage: ./dvd_install.py -n VMname -k KickstartFile -a Arch -i DVD_image" - print "For example:" - print "./dvd_install.py -k http://server/ks.cfg -a i386 -i DVD_image |tee test.log\n" - sys.exit(1) if opt.name == None: vmname = 'fedoratest' else: @@ -342,6 +344,7 @@ if __name__ == '__main__': delete(vmname) (kickstart, kstype) = get_kickstart_file(opt.kickstart) if kstype == 'local': + print "Creating disk to save local kickstart file...." put_local_ks(kickstart) (disk, kickstart) = set_disk(vmname, kickstart, kstype) @@ -363,7 +366,7 @@ if __name__ == '__main__': if anaconda_package_installation(name): closetty(console) time.sleep(5) - print "\n Test is sucessful,system will be shut off..." + print "\nTest is sucessful and test result is pass,system will be shut off..." except (Exception, KeyboardInterrupt), e: print "\nCaught execption.Deleting failed guest."