Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

testcase displaying the loss of the auto-installed flag

git-svn-id: http://opkg.googlecode.com/svn/trunk@634 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
  • Loading branch information...
commit 1d9fe6093125be143fde351305214051afc5ec3b 1 parent e227886
authored January 19, 2012
3  tests/regress/Makefile
@@ -2,7 +2,8 @@ PYTHON=/usr/bin/python3
2 2
 REGRESSION_TESTS=issue26.py issue31.py issue45.py issue46.py \
3 3
 			issue50.py issue51.py issue55.py issue58.py \
4 4
 			issue72.py issue79.py issue84.py issue85.py \
5  
-			filehash.py
  5
+			filehash.py \
  6
+			update_loses_autoinstalled_flag.py
6 7
 
7 8
 regress:
8 9
 	@for test in $(REGRESSION_TESTS); do \
3  tests/regress/opk.py
@@ -70,6 +70,9 @@ def __init__(self):
70 70
 
71 71
 	def add(self, **control):
72 72
 		self.opk_list.append(Opk(**control))
  73
+
  74
+	def addOpk(self, opk):
  75
+		self.opk_list.append(opk)
73 76
 	
74 77
 	def write_opk(self, tar_not_ar=False):
75 78
 		for o in self.opk_list:
13  tests/regress/opkgcl.py
@@ -43,6 +43,19 @@ def is_installed(pkg_name, version=None):
43 43
 		return False
44 44
 	return True
45 45
 
  46
+def is_autoinstalled(pkg_name):
  47
+    status_path = "{}/usr/lib/opkg/status".format(cfg.offline_root)
  48
+    if not os.path.exists(status_path):
  49
+        return False
  50
+    status_file = open(status_path, "r")
  51
+    status = status_file.read()
  52
+    status_file.close()
  53
+    index_start = status.find("Package: {}".format(pkg_name))
  54
+    if index_start < 0:
  55
+        return False
  56
+    index_end = status.find("\n\n", index_start)
  57
+    return status.find("Auto-Installed: yes", index_start, index_end) >= 0
  58
+
46 59
 
47 60
 if __name__ == '__main__':
48 61
 	import sys
63  tests/regress/update_loses_autoinstalled_flag.py
... ...
@@ -0,0 +1,63 @@
  1
+#!/usr/bin/python3
  2
+
  3
+import os
  4
+import opk, cfg, opkgcl
  5
+
  6
+bug = True
  7
+
  8
+opk.regress_init()
  9
+
  10
+open("asdf", "w").close()
  11
+a = opk.Opk(Package="a", Version="1.0", Depends="b")
  12
+a.write()
  13
+b = opk.Opk(Package="b", Version="1.0")
  14
+b.write(data_files=["asdf"])
  15
+
  16
+o = opk.OpkGroup()
  17
+o.addOpk(a)
  18
+o.addOpk(b)
  19
+o.write_list()
  20
+
  21
+opkgcl.update()
  22
+opkgcl.install("a")
  23
+
  24
+if not opkgcl.is_autoinstalled("b"):
  25
+	print("b is not autoinstalled")
  26
+	exit(False)
  27
+
  28
+if (bug):
  29
+	a = opk.Opk(Package="a", Version="2.0", Depends="b")
  30
+	a.write()
  31
+	b = opk.Opk(Package="b", Version="2.0")
  32
+	b.write(data_files=["asdf"])
  33
+
  34
+	o = opk.OpkGroup()
  35
+	o.addOpk(a)
  36
+	o.addOpk(b)
  37
+	o.write_list()
  38
+
  39
+	opkgcl.update()
  40
+	opkgcl.upgrade();
  41
+
  42
+	if not opkgcl.is_autoinstalled("b"):
  43
+		print("b is not autoinstalled anymore")
  44
+		exit(False)
  45
+
  46
+a = opk.Opk(Package="a", Version="3.0")
  47
+a.write(data_files=["asdf"])
  48
+os.unlink("asdf")
  49
+
  50
+o = opk.OpkGroup()
  51
+o.addOpk(a)
  52
+o.write_list()
  53
+
  54
+opkgcl.update()
  55
+opkgcl.upgrade();
  56
+
  57
+if opkgcl.is_installed("b", "2.0"):
  58
+	print("b is still installed")
  59
+	exit(False)
  60
+
  61
+if not opkgcl.is_installed("a", "3.0"):
  62
+	print("a is not installed")
  63
+	exit(False)

0 notes on commit 1d9fe60

Please sign in to comment.
Something went wrong with that request. Please try again.