diff options
author | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2010-09-14 20:39:22 (EDT) |
---|---|---|
committer | graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2010-09-14 20:39:22 (EDT) |
commit | 2ea9af9a660ccf765ab4cd3ef84affa7d77527d0 (patch) | |
tree | 3b2d6bfd3aceb795f2327c36c4d99da5cf74abc9 /tests/regress/opkgcl.py | |
parent | 442cfaa9075c7cdc8839eee9efd6b0e1a662e982 (diff) |
Add simple regression testing code and tests for some issues.
Written with python3 only because I was reading a tutorial and wanted
to do something useful with it.
git-svn-id: http://opkg.googlecode.com/svn/trunk@566 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'tests/regress/opkgcl.py')
-rwxr-xr-x | tests/regress/opkgcl.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/regress/opkgcl.py b/tests/regress/opkgcl.py new file mode 100755 index 0000000..effc5c8 --- /dev/null +++ b/tests/regress/opkgcl.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 + +import os, subprocess +import cfg + +def opkgcl(opkg_args): + cmd = "{} -o {} {}".format(cfg.opkgcl, cfg.offline_root, opkg_args) + #print(cmd) + return subprocess.getstatusoutput(cmd) + +def install(pkg_name, flags=""): + return opkgcl("{} install {}".format(flags, pkg_name))[0] + +def remove(pkg_name, flags=""): + return opkgcl("{} remove {}".format(flags, pkg_name))[0] + +def update(): + return opkgcl("update")[0] + +def upgrade(): + return opkgcl("upgrade")[0] + +def files(pkg_name): + output = opkgcl("files {}".format(pkg_name))[1] + return output.split("\n")[1:] + + +def is_installed(pkg_name, version=None): + out = opkgcl("list_installed {}".format(pkg_name))[1] + if len(out) == 0 or out.split()[0] != pkg_name: + return False + if version and out.split()[2] != version: + return False + if not os.path.exists("{}/usr/lib/opkg/info/{}.control"\ + .format(cfg.offline_root, pkg_name)): + return False + return True + + +if __name__ == '__main__': + import sys + (status, output) = opkgcl(" ".join(sys.argv[1:])) + print(output) + exit(status) |