summaryrefslogtreecommitdiffstats
path: root/tests/regress
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regress')
-rw-r--r--tests/regress/Makefile3
-rw-r--r--tests/regress/opk.py3
-rwxr-xr-xtests/regress/opkgcl.py13
-rw-r--r--tests/regress/update_loses_autoinstalled_flag.py63
4 files changed, 81 insertions, 1 deletions
diff --git a/tests/regress/Makefile b/tests/regress/Makefile
index 4280473..0accb31 100644
--- a/tests/regress/Makefile
+++ b/tests/regress/Makefile
@@ -2,7 +2,8 @@ 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
+ filehash.py \
+ update_loses_autoinstalled_flag.py
regress:
@for test in $(REGRESSION_TESTS); do \
diff --git a/tests/regress/opk.py b/tests/regress/opk.py
index ebfb6ec..f96037e 100644
--- a/tests/regress/opk.py
+++ b/tests/regress/opk.py
@@ -70,6 +70,9 @@ class OpkGroup:
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:
diff --git a/tests/regress/opkgcl.py b/tests/regress/opkgcl.py
index bdd9e1e..47e7dd3 100755
--- a/tests/regress/opkgcl.py
+++ b/tests/regress/opkgcl.py
@@ -43,6 +43,19 @@ def is_installed(pkg_name, version=None):
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
diff --git a/tests/regress/update_loses_autoinstalled_flag.py b/tests/regress/update_loses_autoinstalled_flag.py
new file mode 100644
index 0000000..5ae030c
--- /dev/null
+++ b/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)