From f431cd1a48a6a5186633bf5f16a2d21cb4399e8c Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 09 Feb 2012 10:56:43 -0500 Subject: Initial commit. TODO: Copyright information. Including source code and a patch to add files generated by GNU Autoconf is not very pretty... Running 'make dist' in the SVN trunk to generate a source archive might be better. --- (limited to 'src/tests/regress') diff --git a/src/tests/regress/.svn/all-wcprops b/src/tests/regress/.svn/all-wcprops new file mode 100644 index 0000000..d83bc2c --- /dev/null +++ b/src/tests/regress/.svn/all-wcprops @@ -0,0 +1,113 @@ +K 25 +svn:wc:ra_dav:version-url +V 37 +/svn/!svn/ver/634/trunk/tests/regress +END +opk.py +K 25 +svn:wc:ra_dav:version-url +V 44 +/svn/!svn/ver/634/trunk/tests/regress/opk.py +END +issue31.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue31.py +END +issue50.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue50.py +END +issue51.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue51.py +END +cfg.py +K 25 +svn:wc:ra_dav:version-url +V 44 +/svn/!svn/ver/625/trunk/tests/regress/cfg.py +END +issue26.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue26.py +END +issue72.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue72.py +END +issue45.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue45.py +END +issue55.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue55.py +END +issue46.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue46.py +END +issue84.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/633/trunk/tests/regress/issue84.py +END +issue85.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/633/trunk/tests/regress/issue85.py +END +issue58.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue58.py +END +update_loses_autoinstalled_flag.py +K 25 +svn:wc:ra_dav:version-url +V 72 +/svn/!svn/ver/634/trunk/tests/regress/update_loses_autoinstalled_flag.py +END +issue79.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/632/trunk/tests/regress/issue79.py +END +opkgcl.py +K 25 +svn:wc:ra_dav:version-url +V 47 +/svn/!svn/ver/634/trunk/tests/regress/opkgcl.py +END +filehash.py +K 25 +svn:wc:ra_dav:version-url +V 49 +/svn/!svn/ver/607/trunk/tests/regress/filehash.py +END +Makefile +K 25 +svn:wc:ra_dav:version-url +V 46 +/svn/!svn/ver/634/trunk/tests/regress/Makefile +END diff --git a/src/tests/regress/.svn/entries b/src/tests/regress/.svn/entries new file mode 100644 index 0000000..511df3a --- /dev/null +++ b/src/tests/regress/.svn/entries @@ -0,0 +1,640 @@ +10 + +dir +635 +http://opkg.googlecode.com/svn/trunk/tests/regress +http://opkg.googlecode.com/svn + + + +2012-01-19T13:51:59.790020Z +634 +pixdamix@gmail.com + + + + + + + + + + + + + + +e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 + +opk.py +file + + + + +2012-02-03T08:11:57.351042Z +5042d77e53c77cee8b411296d50f963f +2012-01-19T13:51:59.790020Z +634 +pixdamix@gmail.com + + + + + + + + + + + + + + + + + + + + + +2877 + +issue31.py +file + + + + +2012-02-03T08:11:57.351042Z +5d1ac3bfa7788b1cf80301c1a3a92d04 +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +508 + +issue50.py +file + + + + +2012-02-03T08:11:57.355042Z +21fe4bed9f068d6c70d64e85a710d2e4 +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +886 + +issue51.py +file + + + + +2012-02-03T08:11:57.355042Z +825ba593541ddfbdb22dafb0264d35c4 +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +1519 + +cfg.py +file + + + + +2012-02-03T08:11:57.355042Z +ef3d9028e718a965848082841b791e59 +2011-07-13T11:53:28.244081Z +625 +pixdamix@gmail.com + + + + + + + + + + + + + + + + + + + + + +105 + +issue26.py +file + + + + +2012-02-03T08:11:57.355042Z +7eac6e442e578cf77ef822d00eddd20d +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +769 + +issue72.py +file + + + + +2012-02-03T08:11:57.355042Z +18838b761e8fd311f2a1d0d4b15c843d +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +1495 + +issue45.py +file + + + + +2012-02-03T08:11:57.355042Z +c2a7947d78fad363733248d288d7e88d +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +649 + +issue55.py +file + + + + +2012-02-03T08:11:57.355042Z +efceef4be0907165367b198c6450ea8b +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +530 + +issue46.py +file + + + + +2012-02-03T08:11:57.355042Z +ebe87bdc7e69abcc75efa60b5d633311 +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +906 + +issue84.py +file + + + + +2012-02-03T08:11:57.355042Z +4c43bb8c7aa602242eca9a82690d5f19 +2011-10-27T04:53:01.363575Z +633 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +882 + +issue85.py +file + + + + +2012-02-03T08:11:57.355042Z +b2c52019fae7259e1b544b9e483cc05d +2011-10-27T04:53:01.363575Z +633 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +502 + +issue58.py +file + + + + +2012-02-03T08:11:57.355042Z +4e7dab61a69f31a519f5d343d1e612c0 +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +588 + +update_loses_autoinstalled_flag.py +file + + + + +2012-02-03T08:11:57.355042Z +3f8e7328cd8cdb9b6edaac81c0c190fe +2012-01-19T13:51:59.790020Z +634 +pixdamix@gmail.com + + + + + + + + + + + + + + + + + + + + + +1101 + +issue79.py +file + + + + +2012-02-03T08:11:57.355042Z +af632f0199342dc3c0362631aafe884d +2011-10-23T23:42:50.670289Z +632 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +663 + +opkgcl.py +file + + + + +2012-02-03T08:11:57.355042Z +624d2252b119c9b07de516629e6d546b +2012-01-19T13:51:59.790020Z +634 +pixdamix@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +1762 + +filehash.py +file + + + + +2012-02-03T08:11:57.355042Z +09c39129cb0ccb6491bcaa104124a25d +2011-02-21T04:45:33.007731Z +607 +graham.gower@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +886 + +Makefile +file + + + + +2012-02-03T08:11:57.355042Z +9a157e2971d52870d9bb49c61ad74603 +2012-01-19T13:51:59.790020Z +634 +pixdamix@gmail.com + + + + + + + + + + + + + + + + + + + + + +356 + diff --git a/src/tests/regress/.svn/prop-base/filehash.py.svn-base b/src/tests/regress/.svn/prop-base/filehash.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/filehash.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue26.py.svn-base b/src/tests/regress/.svn/prop-base/issue26.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue26.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue31.py.svn-base b/src/tests/regress/.svn/prop-base/issue31.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue31.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue45.py.svn-base b/src/tests/regress/.svn/prop-base/issue45.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue45.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue46.py.svn-base b/src/tests/regress/.svn/prop-base/issue46.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue46.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue50.py.svn-base b/src/tests/regress/.svn/prop-base/issue50.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue50.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue51.py.svn-base b/src/tests/regress/.svn/prop-base/issue51.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue51.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue55.py.svn-base b/src/tests/regress/.svn/prop-base/issue55.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue55.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue58.py.svn-base b/src/tests/regress/.svn/prop-base/issue58.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue58.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue72.py.svn-base b/src/tests/regress/.svn/prop-base/issue72.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue72.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue79.py.svn-base b/src/tests/regress/.svn/prop-base/issue79.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue79.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue84.py.svn-base b/src/tests/regress/.svn/prop-base/issue84.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue84.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/issue85.py.svn-base b/src/tests/regress/.svn/prop-base/issue85.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/issue85.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/prop-base/opkgcl.py.svn-base b/src/tests/regress/.svn/prop-base/opkgcl.py.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/src/tests/regress/.svn/prop-base/opkgcl.py.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/src/tests/regress/.svn/text-base/Makefile.svn-base b/src/tests/regress/.svn/text-base/Makefile.svn-base new file mode 100644 index 0000000..0accb31 --- /dev/null +++ b/src/tests/regress/.svn/text-base/Makefile.svn-base @@ -0,0 +1,15 @@ +PYTHON=/usr/bin/python3 +REGRESSION_TESTS=issue26.py issue31.py issue45.py issue46.py \ + issue50.py issue51.py issue55.py issue58.py \ + issue72.py issue79.py issue84.py issue85.py \ + filehash.py \ + update_loses_autoinstalled_flag.py + +regress: + @for test in $(REGRESSION_TESTS); do \ + echo $$test; \ + $(PYTHON) $$test; \ + done + +clean: + rm -f *.pyc diff --git a/src/tests/regress/.svn/text-base/cfg.py.svn-base b/src/tests/regress/.svn/text-base/cfg.py.svn-base new file mode 100644 index 0000000..6f78996 --- /dev/null +++ b/src/tests/regress/.svn/text-base/cfg.py.svn-base @@ -0,0 +1,5 @@ +import os + +opkdir = "/tmp/opk" +offline_root = "/tmp/opkg" +opkgcl = os.path.realpath("../../src/opkg-cl") diff --git a/src/tests/regress/.svn/text-base/filehash.py.svn-base b/src/tests/regress/.svn/text-base/filehash.py.svn-base new file mode 100644 index 0000000..e6cbe62 --- /dev/null +++ b/src/tests/regress/.svn/text-base/filehash.py.svn-base @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +open("asdf", "w").close() +a = opk.Opk(Package="a", Version="1.0", Architecture="all") +a.write(data_files=["asdf"]) +b = opk.Opk(Package="b", Version="1.0", Architecture="all") +b.write(data_files=["asdf"]) +os.unlink("asdf") +opkgcl.install("a_1.0_all.opk") + +if not opkgcl.is_installed("a"): + print(__file__, ": Package 'a' not installed.") + exit(False) + +if not os.path.exists("{}/asdf".format(cfg.offline_root)): + print(__file__, ": asdf not created.") + exit(False) + +opkgcl.install("b_1.0_all.opk", "--force-overwrite") + +if "{}/asdf".format(cfg.offline_root) not in opkgcl.files("b"): + print(__file__, ": asdf not claimed by ``b''.") + exit(False) + +if "{}/asdf".format(cfg.offline_root) in opkgcl.files("a"): + print(__file__, ": asdf is still claimed by ``a''.") + exit(False) + +opkgcl.remove("b") +opkgcl.remove("a") diff --git a/src/tests/regress/.svn/text-base/issue26.py.svn-base b/src/tests/regress/.svn/text-base/issue26.py.svn-base new file mode 100644 index 0000000..dd4ef92 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue26.py.svn-base @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Version="2.0") +o.write_opk() +o.write_list() + +# older version, not in Packages list +a1 = opk.Opk(Package="a", Version="1.0") +a1.write() + +opkgcl.update() + +# install v2 from repository +opkgcl.install("a") +if not opkgcl.is_installed("a", "2.0"): + print(__file__, ": Package 'a_2.0' not installed.") + exit(False) + +opkgcl.install("a_1.0_all.opk", "--force-downgrade") +if not opkgcl.is_installed("a", "1.0"): + print(__file__, ": Package 'a_1.0' not installed (1).") + exit(False) + +opkgcl.install("a_1.0_all.opk", "--force-downgrade") +if not opkgcl.is_installed("a", "1.0"): + print(__file__, ": Package 'a_1.0' not installed (2).") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/.svn/text-base/issue31.py.svn-base b/src/tests/regress/.svn/text-base/issue31.py.svn-base new file mode 100644 index 0000000..42e51e3 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue31.py.svn-base @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Depends="b") +o.add(Package="b", Depends="c") +o.write_opk() +o.write_list() + +opkgcl.update() + +opkgcl.install("a") +if opkgcl.is_installed("a"): + print(__file__, ": Package 'a' installed, despite dependency " + "upon a package with an unresolved dependency.") + exit(False) + +if opkgcl.is_installed("b"): + print(__file__, ": Package 'b' installed, " + "despite unresolved dependency.") + exit(False) diff --git a/src/tests/regress/.svn/text-base/issue45.py.svn-base b/src/tests/regress/.svn/text-base/issue45.py.svn-base new file mode 100644 index 0000000..30735f9 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue45.py.svn-base @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Depends="b") +o.add(Package="b") +o.write_opk() +o.write_list() + +opkgcl.update() + +(status, output) = opkgcl.opkgcl("install --force-postinstall a") +ln_a = output.find("Configuring a") +ln_b = output.find("Configuring b") + +if ln_a == -1: + print(__file__, ": Didn't see package 'a' get configured.") + exit(False) + +if ln_b == -1: + print(__file__, ": Didn't see package 'b' get configured.") + exit(False) + +if ln_a < ln_b: + print(__file__, ": Packages 'a' and 'b' configured in wrong order.") + exit(False) + +opkgcl.remove("a") +opkgcl.remove("b") diff --git a/src/tests/regress/.svn/text-base/issue46.py.svn-base b/src/tests/regress/.svn/text-base/issue46.py.svn-base new file mode 100644 index 0000000..ec56941 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue46.py.svn-base @@ -0,0 +1,39 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Version="1.0", Recommends="b") +o.add(Package="b", Version="2.0") +o.write_opk() +o.write_list() + +# prime the status file so 'b' is not installed as a recommendation +status_filename = "{}/usr/lib/opkg/status".format(cfg.offline_root) +f = open(status_filename, "w") +f.write("Package: b\n") +f.write("Version: 1.0\n") +f.write("Architecture: all\n") +f.write("Status: deinstall hold not-installed\n") +f.close() + +opkgcl.update() + +opkgcl.install("a") +if opkgcl.is_installed("b"): + print(__file__, ": Package 'b' installed despite " + "deinstall/hold status.") + exit(False) + +opkgcl.remove("a") +opkgcl.install("a") +if opkgcl.is_installed("b"): + print(__file__, ": Package 'b' installed - deinstall/hold status " + "not retained.") + exit(False) + +opkgcl.remove("a") +open(status_filename, "w").close() diff --git a/src/tests/regress/.svn/text-base/issue50.py.svn-base b/src/tests/regress/.svn/text-base/issue50.py.svn-base new file mode 100644 index 0000000..19897b4 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue50.py.svn-base @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +open("foo", "w").close() +a1 = opk.Opk(Package="a", Version="1.0") +a1.write(data_files=["foo"]) + +opkgcl.install("a_1.0_all.opk") + +o = opk.OpkGroup() +a2 = opk.Opk(Package="a", Version="2.0", Depends="b") +a2.write() +b1 = opk.Opk(Package="b", Version="1.0") +b1.write(data_files=["foo"]) +o.opk_list.append(a2) +o.opk_list.append(b1) +o.write_list() + +os.unlink("foo") + +opkgcl.update() +opkgcl.upgrade() + +if not opkgcl.is_installed("a", "2.0"): + print(__file__, ": Package 'a_2.0' not installed.") + exit(False) + +foo_fullpath = "{}/foo".format(cfg.offline_root) + +if not os.path.exists(foo_fullpath): + print(__file__, ": File 'foo' incorrectly orphaned.") + exit(False) + +if not foo_fullpath in opkgcl.files("b"): + print(__file__, ": Package 'b' does not own file 'foo'.") + exit(False) + +opkgcl.remove("a") +opkgcl.remove("b") diff --git a/src/tests/regress/.svn/text-base/issue51.py.svn-base b/src/tests/regress/.svn/text-base/issue51.py.svn-base new file mode 100644 index 0000000..9849dbc --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue51.py.svn-base @@ -0,0 +1,70 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +open("foo", "w").close() +a1 = opk.Opk(Package="a") +a1.write(data_files=["foo"]) +os.rename("a_1.0_all.opk", "a_with_foo.opk") + +opkgcl.install("a_with_foo.opk") + +# ---- +opkgcl.install("a_with_foo.opk") + +open("bar", "w").close() +o = opk.OpkGroup() +a2 = opk.Opk(Package="a") +a2.write(data_files=["foo", "bar"]) +o.opk_list.append(a2) +o.write_list() + +os.unlink("foo") +os.unlink("bar") + +opkgcl.update() +opkgcl.install("a", "--force-reinstall") + +foo_fullpath = "{}/foo".format(cfg.offline_root) +bar_fullpath = "{}/bar".format(cfg.offline_root) + +if not os.path.exists(foo_fullpath) or not os.path.exists(bar_fullpath): + print(__file__, ": Files foo and/or bar are missing.") + exit(False) + +a_files = opkgcl.files("a") +if not foo_fullpath in a_files or not bar_fullpath in a_files: + print(__file__, ": Package 'a' does not own foo and/or bar.") + exit(False) + +opkgcl.remove("a") + +if os.path.exists(foo_fullpath) or os.path.exists(bar_fullpath): + print(__file__, ": Files foo and/or bar still exist " + "after removal of package 'a'.") + exit(False) + +# ---- +o = opk.OpkGroup() +a2 = opk.Opk(Package="a") +a2.write() +o.opk_list.append(a2) +o.write_list() + + +opkgcl.update() + +opkgcl.install("a", "--force-reinstall") + +if os.path.exists(foo_fullpath): + print(__file__, ": File 'foo' not orphaned as it should be.") + exit(False) + +if foo_fullpath in opkgcl.files("a"): + print(__file__, ": Package 'a' incorrectly owns file 'foo'.") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/.svn/text-base/issue55.py.svn-base b/src/tests/regress/.svn/text-base/issue55.py.svn-base new file mode 100644 index 0000000..8628306 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue55.py.svn-base @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +long_filename = 110*"a" + +os.symlink(long_filename, "linky") +a = opk.Opk(Package="a") +a.write(data_files=["linky"]) +os.unlink("linky") +opkgcl.install("a_1.0_all.opk") + +if not opkgcl.is_installed("a"): + print(__file__, ": Package 'a' not installed.") + exit(False) + +if not os.path.lexists("{}/linky".format(cfg.offline_root)): + print(__file__, ": symlink to file with a name longer than 100 " + "characters not created.") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/.svn/text-base/issue58.py.svn-base b/src/tests/regress/.svn/text-base/issue58.py.svn-base new file mode 100644 index 0000000..72a1854 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue58.py.svn-base @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Recommends="b") +o.add(Package="b") +o.add(Package="c", Recommends="b") +o.write_opk() +o.write_list() + +opkgcl.update() + +opkgcl.install("a") +opkgcl.install("c") + +opkgcl.remove("a", "--autoremove") +if not opkgcl.is_installed("b"): + print(__file__, ": Pacakge 'b' orphaned despite remaining " + "recommending package 'c'.") + exit(False) + +opkgcl.remove("c", "--autoremove") +if opkgcl.is_installed("b"): + print(__file__, ": Recommended package 'b' not autoremoved.") + exit(False) + + diff --git a/src/tests/regress/.svn/text-base/issue72.py.svn-base b/src/tests/regress/.svn/text-base/issue72.py.svn-base new file mode 100644 index 0000000..d0c511b --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue72.py.svn-base @@ -0,0 +1,52 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +long_dir = 110*"a" +long_b = 110*"b" +long_filename = long_dir + "/"+ long_b +long_filename2 = long_dir + "/" + 110*"c" + +os.mkdir(long_dir) +open(long_filename, "w").close() +os.symlink(long_b, long_filename2) +a = opk.Opk(Package="a") +a.write(data_files=[long_dir, long_filename, long_filename2]) +os.unlink(long_filename) +os.unlink(long_filename2) +os.rmdir(long_dir) +opkgcl.install("a_1.0_all.opk") + +if not opkgcl.is_installed("a"): + print(__file__, ": Package 'a' not installed.") + exit(False) + +if not os.path.exists("{}/{}".format(cfg.offline_root, long_dir)): + print(__file__, ": dir with name longer than 100 " + "characters not created.") + exit(False) + +if not os.path.exists("{}/{}".format(cfg.offline_root, long_filename)): + print(__file__, ": file with a name longer than 100 characters, " + "in dir with name longer than 100 characters, " + "not created.") + exit(False) + +if not os.path.lexists("{}/{}".format(cfg.offline_root, long_filename2)): + print(__file__, ": symlink with a name longer than 100 characters, " + "pointing at a file with a name longer than " + "100 characters," + "in dir with name longer than 100 characters, " + "not created.") + exit(False) + +linky = os.path.realpath("{}/{}".format(cfg.offline_root, long_filename2)) +linky_dst = "{}/{}".format(cfg.offline_root, long_filename) +if linky != linky_dst: + print(__file__, ": symlink path truncated.") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/.svn/text-base/issue79.py.svn-base b/src/tests/regress/.svn/text-base/issue79.py.svn-base new file mode 100644 index 0000000..30ba201 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue79.py.svn-base @@ -0,0 +1,33 @@ +#!/usr/bin/python + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Version="1.0", Depends="b") +o.add(Package="b", Version="1.0") +o.add(Package="c", Version="1.0", Depends="b") +o.write_opk() +o.write_list() + +opkgcl.update() +opkgcl.install("a") +opkgcl.install("c") + +opkgcl.flag_unpacked("a") + +o = opk.OpkGroup() +o.add(Package="a", Version="1.0", Depends="b") +o.add(Package="b", Version="1.0") +o.add(Package="c", Version="2.0") +o.write_opk() +o.write_list() + +opkgcl.update() +opkgcl.upgrade("--autoremove") + +if not opkgcl.is_installed("b", "1.0"): + print("b has been removed even though a still depends on it") + exit(False) diff --git a/src/tests/regress/.svn/text-base/issue84.py.svn-base b/src/tests/regress/.svn/text-base/issue84.py.svn-base new file mode 100644 index 0000000..1f5d43e --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue84.py.svn-base @@ -0,0 +1,45 @@ +#!/usr/bin/python3 + +import opk, cfg, opkgcl + +def cleanup(): + opkgcl.remove("a1") + opkgcl.remove("b1") + opkgcl.remove("a") + opkgcl.remove("b") + opkgcl.remove('c') + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Provides="v", Depends="a1") +o.add(Package="b", Provides="v", Depends="b1") +o.add(Package="c", Depends="v") +o.add(Package="a1") +o.add(Package="b1") + +o.write_opk() +o.write_list() + +opkgcl.update() + +# install ``a1`` directly +opkgcl.install("a1_1.0_all.opk") +if not opkgcl.is_installed("a1"): + print(__file__, ": package ``a1'' not installed.") + cleanup() + exit(False) + +# install ``c'' from repository +opkgcl.install("c") +if not opkgcl.is_installed("c"): + print(__file__, ": package ``c'' not installed.") + cleanup() + exit(False) + +if opkgcl.is_installed("b1"): + print(__file__, ": package ``b1'' is installed, but should not be.") + cleanup() + exit(False) + +cleanup() diff --git a/src/tests/regress/.svn/text-base/issue85.py.svn-base b/src/tests/regress/.svn/text-base/issue85.py.svn-base new file mode 100644 index 0000000..3250075 --- /dev/null +++ b/src/tests/regress/.svn/text-base/issue85.py.svn-base @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import opk, cfg, opkgcl + +def cleanup(): + opkgcl.remove("a") + opkgcl.remove("b") + opkgcl.remove('c') + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Provides="v") +o.add(Package="b", Provides="v", Depends="b_nonexistant") +o.add(Package="c", Depends="v") + +o.write_opk() +o.write_list() + +opkgcl.update() + +# install ``c'' from repository +opkgcl.install("c") +if not opkgcl.is_installed("c"): + print(__file__, ": package ``c'' not installed.") + cleanup() + exit(False) + +cleanup() diff --git a/src/tests/regress/.svn/text-base/opk.py.svn-base b/src/tests/regress/.svn/text-base/opk.py.svn-base new file mode 100644 index 0000000..f96037e --- /dev/null +++ b/src/tests/regress/.svn/text-base/opk.py.svn-base @@ -0,0 +1,111 @@ +import tarfile, os +import cfg + +class Opk: + valid_control_fields = ["Package", "Version", "Depends", "Provides",\ + "Replaces", "Conflicts", "Suggests", "Recommends",\ + "Section", "Architecture", "Maintainer", "MD5Sum",\ + "Size", "InstalledSize", "Filename", "Source",\ + "Description", "OE", "Homepage", "Priority",\ + "Conffiles"] + + def __init__(self, **control): + for k in control.keys(): + if k not in self.valid_control_fields: + raise Exception("Invalid control field: " + "{}".format(k)) + if "Package" not in control.keys(): + print("Cannot create opk without Package name.\n") + return None + if "Architecture" not in control.keys(): + control["Architecture"] = "all" + if "Version" not in control.keys(): + control["Version"] = "1.0" + self.control = control + + def write(self, tar_not_ar=False, data_files=None): + filename = "{Package}_{Version}_{Architecture}.opk"\ + .format(**self.control) + if os.path.exists(filename): + os.unlink(filename) + if os.path.exists("control"): + os.unlink("control") + if os.path.exists("control.tar.gz"): + os.unlink("control.tar.gz") + if os.path.exists("data.tar.gz"): + os.unlink("data.tar.gz") + + f = open("control", "w") + for k in self.control.keys(): + f.write("{}: {}\n".format(k, self.control[k])) + f.close() + + tar = tarfile.open("control.tar.gz", "w:gz") + tar.add("control") + tar.close() + + tar = tarfile.open("data.tar.gz", "w:gz") + if data_files: + for df in data_files: + tar.add(df) + tar.close() + + + if tar_not_ar: + tar = tarfile.open(filename, "w:gz") + tar.add("control.tar.gz") + tar.add("data.tar.gz") + tar.close() + else: + os.system("ar q {} control.tar.gz data.tar.gz \ + 2>/dev/null".format(filename)) + + os.unlink("control") + os.unlink("control.tar.gz") + os.unlink("data.tar.gz") + +class OpkGroup: + def __init__(self): + self.opk_list = [] + + def add(self, **control): + self.opk_list.append(Opk(**control)) + + def addOpk(self, opk): + self.opk_list.append(opk) + + def write_opk(self, tar_not_ar=False): + for o in self.opk_list: + o.write(tar_not_ar) + + def write_list(self, filename="Packages"): + f = open(filename, "w") + for opk in self.opk_list: + for k in opk.control.keys(): + f.write("{}: {}\n".format(k, opk.control[k])) + f.write("Filename: {Package}_{Version}_{Architecture}" + ".opk\n".format(**opk.control)) + f.write("\n") + f.close() + + +def regress_init(): + """ + Initialisation and sanity checking. + """ + + if not os.access(cfg.opkgcl, os.X_OK): + print("Cannot exec {}".format(cfg.opkgcl)) + exit(False) + + os.chdir(cfg.opkdir) + + os.system("rm -fr {}".format(cfg.offline_root)) + + os.makedirs("{}/usr/lib/opkg".format(cfg.offline_root)) + os.makedirs("{}/etc/opkg".format(cfg.offline_root)) + + f = open("{}/etc/opkg/opkg.conf".format(cfg.offline_root), "w") + f.write("arch all 1\n") + f.write("src test file:{}\n".format(cfg.opkdir)) + f.close() diff --git a/src/tests/regress/.svn/text-base/opkgcl.py.svn-base b/src/tests/regress/.svn/text-base/opkgcl.py.svn-base new file mode 100644 index 0000000..47e7dd3 --- /dev/null +++ b/src/tests/regress/.svn/text-base/opkgcl.py.svn-base @@ -0,0 +1,64 @@ +#!/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(params=None): + if params: + opkgcl("upgrade {}".format(params))[0] + else: + return opkgcl("upgrade")[0] + +def files(pkg_name): + output = opkgcl("files {}".format(pkg_name))[1] + return output.split("\n")[1:] + + +def flag_unpacked(pkg_name): + out = opkgcl("flag unpacked {}".format(pkg_name)) + return out == "Setting flags for package {} to unpacked.".format(pkg_name) + +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 + +def is_autoinstalled(pkg_name): + status_path = "{}/usr/lib/opkg/status".format(cfg.offline_root) + if not os.path.exists(status_path): + return False + status_file = open(status_path, "r") + status = status_file.read() + status_file.close() + index_start = status.find("Package: {}".format(pkg_name)) + if index_start < 0: + return False + index_end = status.find("\n\n", index_start) + return status.find("Auto-Installed: yes", index_start, index_end) >= 0 + + +if __name__ == '__main__': + import sys + (status, output) = opkgcl(" ".join(sys.argv[1:])) + print(output) + exit(status) diff --git a/src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base b/src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base new file mode 100644 index 0000000..5ae030c --- /dev/null +++ b/src/tests/regress/.svn/text-base/update_loses_autoinstalled_flag.py.svn-base @@ -0,0 +1,63 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +bug = True + +opk.regress_init() + +open("asdf", "w").close() +a = opk.Opk(Package="a", Version="1.0", Depends="b") +a.write() +b = opk.Opk(Package="b", Version="1.0") +b.write(data_files=["asdf"]) + +o = opk.OpkGroup() +o.addOpk(a) +o.addOpk(b) +o.write_list() + +opkgcl.update() +opkgcl.install("a") + +if not opkgcl.is_autoinstalled("b"): + print("b is not autoinstalled") + exit(False) + +if (bug): + a = opk.Opk(Package="a", Version="2.0", Depends="b") + a.write() + b = opk.Opk(Package="b", Version="2.0") + b.write(data_files=["asdf"]) + + o = opk.OpkGroup() + o.addOpk(a) + o.addOpk(b) + o.write_list() + + opkgcl.update() + opkgcl.upgrade(); + + if not opkgcl.is_autoinstalled("b"): + print("b is not autoinstalled anymore") + exit(False) + +a = opk.Opk(Package="a", Version="3.0") +a.write(data_files=["asdf"]) +os.unlink("asdf") + +o = opk.OpkGroup() +o.addOpk(a) +o.write_list() + +opkgcl.update() +opkgcl.upgrade(); + +if opkgcl.is_installed("b", "2.0"): + print("b is still installed") + exit(False) + +if not opkgcl.is_installed("a", "3.0"): + print("a is not installed") + exit(False) diff --git a/src/tests/regress/Makefile b/src/tests/regress/Makefile new file mode 100644 index 0000000..0accb31 --- /dev/null +++ b/src/tests/regress/Makefile @@ -0,0 +1,15 @@ +PYTHON=/usr/bin/python3 +REGRESSION_TESTS=issue26.py issue31.py issue45.py issue46.py \ + issue50.py issue51.py issue55.py issue58.py \ + issue72.py issue79.py issue84.py issue85.py \ + filehash.py \ + update_loses_autoinstalled_flag.py + +regress: + @for test in $(REGRESSION_TESTS); do \ + echo $$test; \ + $(PYTHON) $$test; \ + done + +clean: + rm -f *.pyc diff --git a/src/tests/regress/cfg.py b/src/tests/regress/cfg.py new file mode 100644 index 0000000..6f78996 --- /dev/null +++ b/src/tests/regress/cfg.py @@ -0,0 +1,5 @@ +import os + +opkdir = "/tmp/opk" +offline_root = "/tmp/opkg" +opkgcl = os.path.realpath("../../src/opkg-cl") diff --git a/src/tests/regress/filehash.py b/src/tests/regress/filehash.py new file mode 100755 index 0000000..e6cbe62 --- /dev/null +++ b/src/tests/regress/filehash.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +open("asdf", "w").close() +a = opk.Opk(Package="a", Version="1.0", Architecture="all") +a.write(data_files=["asdf"]) +b = opk.Opk(Package="b", Version="1.0", Architecture="all") +b.write(data_files=["asdf"]) +os.unlink("asdf") +opkgcl.install("a_1.0_all.opk") + +if not opkgcl.is_installed("a"): + print(__file__, ": Package 'a' not installed.") + exit(False) + +if not os.path.exists("{}/asdf".format(cfg.offline_root)): + print(__file__, ": asdf not created.") + exit(False) + +opkgcl.install("b_1.0_all.opk", "--force-overwrite") + +if "{}/asdf".format(cfg.offline_root) not in opkgcl.files("b"): + print(__file__, ": asdf not claimed by ``b''.") + exit(False) + +if "{}/asdf".format(cfg.offline_root) in opkgcl.files("a"): + print(__file__, ": asdf is still claimed by ``a''.") + exit(False) + +opkgcl.remove("b") +opkgcl.remove("a") diff --git a/src/tests/regress/issue26.py b/src/tests/regress/issue26.py new file mode 100755 index 0000000..dd4ef92 --- /dev/null +++ b/src/tests/regress/issue26.py @@ -0,0 +1,35 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Version="2.0") +o.write_opk() +o.write_list() + +# older version, not in Packages list +a1 = opk.Opk(Package="a", Version="1.0") +a1.write() + +opkgcl.update() + +# install v2 from repository +opkgcl.install("a") +if not opkgcl.is_installed("a", "2.0"): + print(__file__, ": Package 'a_2.0' not installed.") + exit(False) + +opkgcl.install("a_1.0_all.opk", "--force-downgrade") +if not opkgcl.is_installed("a", "1.0"): + print(__file__, ": Package 'a_1.0' not installed (1).") + exit(False) + +opkgcl.install("a_1.0_all.opk", "--force-downgrade") +if not opkgcl.is_installed("a", "1.0"): + print(__file__, ": Package 'a_1.0' not installed (2).") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/issue31.py b/src/tests/regress/issue31.py new file mode 100755 index 0000000..42e51e3 --- /dev/null +++ b/src/tests/regress/issue31.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Depends="b") +o.add(Package="b", Depends="c") +o.write_opk() +o.write_list() + +opkgcl.update() + +opkgcl.install("a") +if opkgcl.is_installed("a"): + print(__file__, ": Package 'a' installed, despite dependency " + "upon a package with an unresolved dependency.") + exit(False) + +if opkgcl.is_installed("b"): + print(__file__, ": Package 'b' installed, " + "despite unresolved dependency.") + exit(False) diff --git a/src/tests/regress/issue45.py b/src/tests/regress/issue45.py new file mode 100755 index 0000000..30735f9 --- /dev/null +++ b/src/tests/regress/issue45.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Depends="b") +o.add(Package="b") +o.write_opk() +o.write_list() + +opkgcl.update() + +(status, output) = opkgcl.opkgcl("install --force-postinstall a") +ln_a = output.find("Configuring a") +ln_b = output.find("Configuring b") + +if ln_a == -1: + print(__file__, ": Didn't see package 'a' get configured.") + exit(False) + +if ln_b == -1: + print(__file__, ": Didn't see package 'b' get configured.") + exit(False) + +if ln_a < ln_b: + print(__file__, ": Packages 'a' and 'b' configured in wrong order.") + exit(False) + +opkgcl.remove("a") +opkgcl.remove("b") diff --git a/src/tests/regress/issue46.py b/src/tests/regress/issue46.py new file mode 100755 index 0000000..ec56941 --- /dev/null +++ b/src/tests/regress/issue46.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Version="1.0", Recommends="b") +o.add(Package="b", Version="2.0") +o.write_opk() +o.write_list() + +# prime the status file so 'b' is not installed as a recommendation +status_filename = "{}/usr/lib/opkg/status".format(cfg.offline_root) +f = open(status_filename, "w") +f.write("Package: b\n") +f.write("Version: 1.0\n") +f.write("Architecture: all\n") +f.write("Status: deinstall hold not-installed\n") +f.close() + +opkgcl.update() + +opkgcl.install("a") +if opkgcl.is_installed("b"): + print(__file__, ": Package 'b' installed despite " + "deinstall/hold status.") + exit(False) + +opkgcl.remove("a") +opkgcl.install("a") +if opkgcl.is_installed("b"): + print(__file__, ": Package 'b' installed - deinstall/hold status " + "not retained.") + exit(False) + +opkgcl.remove("a") +open(status_filename, "w").close() diff --git a/src/tests/regress/issue50.py b/src/tests/regress/issue50.py new file mode 100755 index 0000000..19897b4 --- /dev/null +++ b/src/tests/regress/issue50.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +open("foo", "w").close() +a1 = opk.Opk(Package="a", Version="1.0") +a1.write(data_files=["foo"]) + +opkgcl.install("a_1.0_all.opk") + +o = opk.OpkGroup() +a2 = opk.Opk(Package="a", Version="2.0", Depends="b") +a2.write() +b1 = opk.Opk(Package="b", Version="1.0") +b1.write(data_files=["foo"]) +o.opk_list.append(a2) +o.opk_list.append(b1) +o.write_list() + +os.unlink("foo") + +opkgcl.update() +opkgcl.upgrade() + +if not opkgcl.is_installed("a", "2.0"): + print(__file__, ": Package 'a_2.0' not installed.") + exit(False) + +foo_fullpath = "{}/foo".format(cfg.offline_root) + +if not os.path.exists(foo_fullpath): + print(__file__, ": File 'foo' incorrectly orphaned.") + exit(False) + +if not foo_fullpath in opkgcl.files("b"): + print(__file__, ": Package 'b' does not own file 'foo'.") + exit(False) + +opkgcl.remove("a") +opkgcl.remove("b") diff --git a/src/tests/regress/issue51.py b/src/tests/regress/issue51.py new file mode 100755 index 0000000..9849dbc --- /dev/null +++ b/src/tests/regress/issue51.py @@ -0,0 +1,70 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +open("foo", "w").close() +a1 = opk.Opk(Package="a") +a1.write(data_files=["foo"]) +os.rename("a_1.0_all.opk", "a_with_foo.opk") + +opkgcl.install("a_with_foo.opk") + +# ---- +opkgcl.install("a_with_foo.opk") + +open("bar", "w").close() +o = opk.OpkGroup() +a2 = opk.Opk(Package="a") +a2.write(data_files=["foo", "bar"]) +o.opk_list.append(a2) +o.write_list() + +os.unlink("foo") +os.unlink("bar") + +opkgcl.update() +opkgcl.install("a", "--force-reinstall") + +foo_fullpath = "{}/foo".format(cfg.offline_root) +bar_fullpath = "{}/bar".format(cfg.offline_root) + +if not os.path.exists(foo_fullpath) or not os.path.exists(bar_fullpath): + print(__file__, ": Files foo and/or bar are missing.") + exit(False) + +a_files = opkgcl.files("a") +if not foo_fullpath in a_files or not bar_fullpath in a_files: + print(__file__, ": Package 'a' does not own foo and/or bar.") + exit(False) + +opkgcl.remove("a") + +if os.path.exists(foo_fullpath) or os.path.exists(bar_fullpath): + print(__file__, ": Files foo and/or bar still exist " + "after removal of package 'a'.") + exit(False) + +# ---- +o = opk.OpkGroup() +a2 = opk.Opk(Package="a") +a2.write() +o.opk_list.append(a2) +o.write_list() + + +opkgcl.update() + +opkgcl.install("a", "--force-reinstall") + +if os.path.exists(foo_fullpath): + print(__file__, ": File 'foo' not orphaned as it should be.") + exit(False) + +if foo_fullpath in opkgcl.files("a"): + print(__file__, ": Package 'a' incorrectly owns file 'foo'.") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/issue55.py b/src/tests/regress/issue55.py new file mode 100755 index 0000000..8628306 --- /dev/null +++ b/src/tests/regress/issue55.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +long_filename = 110*"a" + +os.symlink(long_filename, "linky") +a = opk.Opk(Package="a") +a.write(data_files=["linky"]) +os.unlink("linky") +opkgcl.install("a_1.0_all.opk") + +if not opkgcl.is_installed("a"): + print(__file__, ": Package 'a' not installed.") + exit(False) + +if not os.path.lexists("{}/linky".format(cfg.offline_root)): + print(__file__, ": symlink to file with a name longer than 100 " + "characters not created.") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/issue58.py b/src/tests/regress/issue58.py new file mode 100755 index 0000000..72a1854 --- /dev/null +++ b/src/tests/regress/issue58.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Recommends="b") +o.add(Package="b") +o.add(Package="c", Recommends="b") +o.write_opk() +o.write_list() + +opkgcl.update() + +opkgcl.install("a") +opkgcl.install("c") + +opkgcl.remove("a", "--autoremove") +if not opkgcl.is_installed("b"): + print(__file__, ": Pacakge 'b' orphaned despite remaining " + "recommending package 'c'.") + exit(False) + +opkgcl.remove("c", "--autoremove") +if opkgcl.is_installed("b"): + print(__file__, ": Recommended package 'b' not autoremoved.") + exit(False) + + diff --git a/src/tests/regress/issue72.py b/src/tests/regress/issue72.py new file mode 100755 index 0000000..d0c511b --- /dev/null +++ b/src/tests/regress/issue72.py @@ -0,0 +1,52 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +long_dir = 110*"a" +long_b = 110*"b" +long_filename = long_dir + "/"+ long_b +long_filename2 = long_dir + "/" + 110*"c" + +os.mkdir(long_dir) +open(long_filename, "w").close() +os.symlink(long_b, long_filename2) +a = opk.Opk(Package="a") +a.write(data_files=[long_dir, long_filename, long_filename2]) +os.unlink(long_filename) +os.unlink(long_filename2) +os.rmdir(long_dir) +opkgcl.install("a_1.0_all.opk") + +if not opkgcl.is_installed("a"): + print(__file__, ": Package 'a' not installed.") + exit(False) + +if not os.path.exists("{}/{}".format(cfg.offline_root, long_dir)): + print(__file__, ": dir with name longer than 100 " + "characters not created.") + exit(False) + +if not os.path.exists("{}/{}".format(cfg.offline_root, long_filename)): + print(__file__, ": file with a name longer than 100 characters, " + "in dir with name longer than 100 characters, " + "not created.") + exit(False) + +if not os.path.lexists("{}/{}".format(cfg.offline_root, long_filename2)): + print(__file__, ": symlink with a name longer than 100 characters, " + "pointing at a file with a name longer than " + "100 characters," + "in dir with name longer than 100 characters, " + "not created.") + exit(False) + +linky = os.path.realpath("{}/{}".format(cfg.offline_root, long_filename2)) +linky_dst = "{}/{}".format(cfg.offline_root, long_filename) +if linky != linky_dst: + print(__file__, ": symlink path truncated.") + exit(False) + +opkgcl.remove("a") diff --git a/src/tests/regress/issue79.py b/src/tests/regress/issue79.py new file mode 100755 index 0000000..30ba201 --- /dev/null +++ b/src/tests/regress/issue79.py @@ -0,0 +1,33 @@ +#!/usr/bin/python + +import os +import opk, cfg, opkgcl + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Version="1.0", Depends="b") +o.add(Package="b", Version="1.0") +o.add(Package="c", Version="1.0", Depends="b") +o.write_opk() +o.write_list() + +opkgcl.update() +opkgcl.install("a") +opkgcl.install("c") + +opkgcl.flag_unpacked("a") + +o = opk.OpkGroup() +o.add(Package="a", Version="1.0", Depends="b") +o.add(Package="b", Version="1.0") +o.add(Package="c", Version="2.0") +o.write_opk() +o.write_list() + +opkgcl.update() +opkgcl.upgrade("--autoremove") + +if not opkgcl.is_installed("b", "1.0"): + print("b has been removed even though a still depends on it") + exit(False) diff --git a/src/tests/regress/issue84.py b/src/tests/regress/issue84.py new file mode 100755 index 0000000..1f5d43e --- /dev/null +++ b/src/tests/regress/issue84.py @@ -0,0 +1,45 @@ +#!/usr/bin/python3 + +import opk, cfg, opkgcl + +def cleanup(): + opkgcl.remove("a1") + opkgcl.remove("b1") + opkgcl.remove("a") + opkgcl.remove("b") + opkgcl.remove('c') + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Provides="v", Depends="a1") +o.add(Package="b", Provides="v", Depends="b1") +o.add(Package="c", Depends="v") +o.add(Package="a1") +o.add(Package="b1") + +o.write_opk() +o.write_list() + +opkgcl.update() + +# install ``a1`` directly +opkgcl.install("a1_1.0_all.opk") +if not opkgcl.is_installed("a1"): + print(__file__, ": package ``a1'' not installed.") + cleanup() + exit(False) + +# install ``c'' from repository +opkgcl.install("c") +if not opkgcl.is_installed("c"): + print(__file__, ": package ``c'' not installed.") + cleanup() + exit(False) + +if opkgcl.is_installed("b1"): + print(__file__, ": package ``b1'' is installed, but should not be.") + cleanup() + exit(False) + +cleanup() diff --git a/src/tests/regress/issue85.py b/src/tests/regress/issue85.py new file mode 100755 index 0000000..3250075 --- /dev/null +++ b/src/tests/regress/issue85.py @@ -0,0 +1,29 @@ +#!/usr/bin/python3 + +import opk, cfg, opkgcl + +def cleanup(): + opkgcl.remove("a") + opkgcl.remove("b") + opkgcl.remove('c') + +opk.regress_init() + +o = opk.OpkGroup() +o.add(Package="a", Provides="v") +o.add(Package="b", Provides="v", Depends="b_nonexistant") +o.add(Package="c", Depends="v") + +o.write_opk() +o.write_list() + +opkgcl.update() + +# install ``c'' from repository +opkgcl.install("c") +if not opkgcl.is_installed("c"): + print(__file__, ": package ``c'' not installed.") + cleanup() + exit(False) + +cleanup() diff --git a/src/tests/regress/opk.py b/src/tests/regress/opk.py new file mode 100644 index 0000000..f96037e --- /dev/null +++ b/src/tests/regress/opk.py @@ -0,0 +1,111 @@ +import tarfile, os +import cfg + +class Opk: + valid_control_fields = ["Package", "Version", "Depends", "Provides",\ + "Replaces", "Conflicts", "Suggests", "Recommends",\ + "Section", "Architecture", "Maintainer", "MD5Sum",\ + "Size", "InstalledSize", "Filename", "Source",\ + "Description", "OE", "Homepage", "Priority",\ + "Conffiles"] + + def __init__(self, **control): + for k in control.keys(): + if k not in self.valid_control_fields: + raise Exception("Invalid control field: " + "{}".format(k)) + if "Package" not in control.keys(): + print("Cannot create opk without Package name.\n") + return None + if "Architecture" not in control.keys(): + control["Architecture"] = "all" + if "Version" not in control.keys(): + control["Version"] = "1.0" + self.control = control + + def write(self, tar_not_ar=False, data_files=None): + filename = "{Package}_{Version}_{Architecture}.opk"\ + .format(**self.control) + if os.path.exists(filename): + os.unlink(filename) + if os.path.exists("control"): + os.unlink("control") + if os.path.exists("control.tar.gz"): + os.unlink("control.tar.gz") + if os.path.exists("data.tar.gz"): + os.unlink("data.tar.gz") + + f = open("control", "w") + for k in self.control.keys(): + f.write("{}: {}\n".format(k, self.control[k])) + f.close() + + tar = tarfile.open("control.tar.gz", "w:gz") + tar.add("control") + tar.close() + + tar = tarfile.open("data.tar.gz", "w:gz") + if data_files: + for df in data_files: + tar.add(df) + tar.close() + + + if tar_not_ar: + tar = tarfile.open(filename, "w:gz") + tar.add("control.tar.gz") + tar.add("data.tar.gz") + tar.close() + else: + os.system("ar q {} control.tar.gz data.tar.gz \ + 2>/dev/null".format(filename)) + + os.unlink("control") + os.unlink("control.tar.gz") + os.unlink("data.tar.gz") + +class OpkGroup: + def __init__(self): + self.opk_list = [] + + def add(self, **control): + self.opk_list.append(Opk(**control)) + + def addOpk(self, opk): + self.opk_list.append(opk) + + def write_opk(self, tar_not_ar=False): + for o in self.opk_list: + o.write(tar_not_ar) + + def write_list(self, filename="Packages"): + f = open(filename, "w") + for opk in self.opk_list: + for k in opk.control.keys(): + f.write("{}: {}\n".format(k, opk.control[k])) + f.write("Filename: {Package}_{Version}_{Architecture}" + ".opk\n".format(**opk.control)) + f.write("\n") + f.close() + + +def regress_init(): + """ + Initialisation and sanity checking. + """ + + if not os.access(cfg.opkgcl, os.X_OK): + print("Cannot exec {}".format(cfg.opkgcl)) + exit(False) + + os.chdir(cfg.opkdir) + + os.system("rm -fr {}".format(cfg.offline_root)) + + os.makedirs("{}/usr/lib/opkg".format(cfg.offline_root)) + os.makedirs("{}/etc/opkg".format(cfg.offline_root)) + + f = open("{}/etc/opkg/opkg.conf".format(cfg.offline_root), "w") + f.write("arch all 1\n") + f.write("src test file:{}\n".format(cfg.opkdir)) + f.close() diff --git a/src/tests/regress/opkgcl.py b/src/tests/regress/opkgcl.py new file mode 100755 index 0000000..47e7dd3 --- /dev/null +++ b/src/tests/regress/opkgcl.py @@ -0,0 +1,64 @@ +#!/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(params=None): + if params: + opkgcl("upgrade {}".format(params))[0] + else: + return opkgcl("upgrade")[0] + +def files(pkg_name): + output = opkgcl("files {}".format(pkg_name))[1] + return output.split("\n")[1:] + + +def flag_unpacked(pkg_name): + out = opkgcl("flag unpacked {}".format(pkg_name)) + return out == "Setting flags for package {} to unpacked.".format(pkg_name) + +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 + +def is_autoinstalled(pkg_name): + status_path = "{}/usr/lib/opkg/status".format(cfg.offline_root) + if not os.path.exists(status_path): + return False + status_file = open(status_path, "r") + status = status_file.read() + status_file.close() + index_start = status.find("Package: {}".format(pkg_name)) + if index_start < 0: + return False + index_end = status.find("\n\n", index_start) + return status.find("Auto-Installed: yes", index_start, index_end) >= 0 + + +if __name__ == '__main__': + import sys + (status, output) = opkgcl(" ".join(sys.argv[1:])) + print(output) + exit(status) diff --git a/src/tests/regress/update_loses_autoinstalled_flag.py b/src/tests/regress/update_loses_autoinstalled_flag.py new file mode 100644 index 0000000..5ae030c --- /dev/null +++ b/src/tests/regress/update_loses_autoinstalled_flag.py @@ -0,0 +1,63 @@ +#!/usr/bin/python3 + +import os +import opk, cfg, opkgcl + +bug = True + +opk.regress_init() + +open("asdf", "w").close() +a = opk.Opk(Package="a", Version="1.0", Depends="b") +a.write() +b = opk.Opk(Package="b", Version="1.0") +b.write(data_files=["asdf"]) + +o = opk.OpkGroup() +o.addOpk(a) +o.addOpk(b) +o.write_list() + +opkgcl.update() +opkgcl.install("a") + +if not opkgcl.is_autoinstalled("b"): + print("b is not autoinstalled") + exit(False) + +if (bug): + a = opk.Opk(Package="a", Version="2.0", Depends="b") + a.write() + b = opk.Opk(Package="b", Version="2.0") + b.write(data_files=["asdf"]) + + o = opk.OpkGroup() + o.addOpk(a) + o.addOpk(b) + o.write_list() + + opkgcl.update() + opkgcl.upgrade(); + + if not opkgcl.is_autoinstalled("b"): + print("b is not autoinstalled anymore") + exit(False) + +a = opk.Opk(Package="a", Version="3.0") +a.write(data_files=["asdf"]) +os.unlink("asdf") + +o = opk.OpkGroup() +o.addOpk(a) +o.write_list() + +opkgcl.update() +opkgcl.upgrade(); + +if opkgcl.is_installed("b", "2.0"): + print("b is still installed") + exit(False) + +if not opkgcl.is_installed("a", "3.0"): + print("a is not installed") + exit(False) -- cgit v0.9.1