I'm working on rewriting the test harness for the CLI testing in
terms of python's unittest framework, to achieve a higher level of
uniformity among our test cases, and also cut down the time it
takes to develop a new test case.
At the end of this mail I've included a sample test case using
my new harness. Feedback appreciated on the usability of this
sort of API.
Notably, all of the error checking is built into the superclass
infrastructure-- so if something exits with an unexpected status or
does a traceback, we get an exception and therefore a traceback.
The depot is created for you before the test case starts and shutdown
at the end. The whole pkgsend PKG_TRANS_ID stuff is all taken care
of automagically by the "pkgsend()" routine.
The code is also designed (although not implemented) so that we should
be able to drop in a "TwoDepotTestCase" superclass which starts up
multiple depots, similar to our existing two-depot.ksh tests.
Running the attached code yields:
xanadu # python t_pkg_install_basics.py
.
----------------------------------------------------------------------
Ran 1 test in 2.707s
Something going wrong looks like this (contrived example):
E
======================================================================
ERROR: Send empty package [EMAIL PROTECTED], install and uninstall
----------------------------------------------------------------------
Traceback (most recent call last):
File "t_pkg_install_basics.py", line 51, in test_basics_1
self.pkg("verify", exit = 1)
File "/net/snowdog/aux/dp/ips-fixes/gate/src/tests/cli/testutils.py", line
94, in pkg
raise UnexpectedReturnException(output)
UnexpectedReturnException
----------------------------------------------------------------------
Ran 1 test in 2.706s
FAILED (errors=1)
Comments appreciated,
-dp
----------------- ----------------- ----------------- -----------------
#!/usr/bin/python
#
import unittest
import os
import testutils
class TestPkgInstallBasics(testutils.SingleDepotTestCase):
def test_basics_1(self):
""" Send empty package [EMAIL PROTECTED], install and uninstall
"""
durl = self.dc.get_depot_url()
self.pkgsend(durl, "open [EMAIL PROTECTED],5.11-0")
self.pkgsend(durl, "close")
self.image_create(durl)
self.pkg("status -a")
self.pkg("status", exit=1)
self.pkg("install foo")
self.pkg("status")
self.pkg("verify")
self.pkg("uninstall foo")
self.pkg("verify")
if __name__ == "__main__":
unittest.main()
----------------- ----------------- ----------------- -----------------
--
Daniel Price - Solaris Kernel Engineering - [EMAIL PROTECTED] - blogs.sun.com/dp
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss