Add regress test for issue72.
[oweals/opkg-lede.git] / tests / regress / issue72.py
1 #!/usr/bin/python3
2
3 import os
4 import opk, cfg, opkgcl
5
6 opk.regress_init()
7
8 long_dir = 110*"a"
9 long_b = 110*"b"
10 long_filename = long_dir + "/"+ long_b
11 long_filename2 = long_dir + "/" + 110*"c"
12
13 os.mkdir(long_dir)
14 open(long_filename, "w").close()
15 os.symlink(long_b, long_filename2)
16 a = opk.Opk(Package="a", Version="1.0", Architecture="all")
17 a.write(data_files=[long_dir, long_filename, long_filename2])
18 os.unlink(long_filename)
19 os.unlink(long_filename2)
20 os.rmdir(long_dir)
21 opkgcl.install("a_1.0_all.opk")
22
23 if not opkgcl.is_installed("a"):
24         print(__file__, ": Package 'a' not installed.")
25         exit(False)
26
27 if not os.path.exists("{}/{}".format(cfg.offline_root, long_dir)):
28         print(__file__, ": dir with name longer than 100 "
29                                         "characters not created.")
30         exit(False)
31
32 if not os.path.exists("{}/{}".format(cfg.offline_root, long_filename)):
33         print(__file__, ": file with a name longer than 100 characters, "
34                                 "in dir with name longer than 100 characters, "
35                                 "not created.")
36         exit(False)
37
38 if not os.path.lexists("{}/{}".format(cfg.offline_root, long_filename2)):
39         print(__file__, ": symlink with a name longer than 100 characters, "
40                                 "pointing at a file with a name longer than "
41                                 "100 characters,"
42                                 "in dir with name longer than 100 characters, "
43                                 "not created.")
44         exit(False)
45
46 linky = os.path.realpath("{}/{}".format(cfg.offline_root, long_filename2))
47 linky_dst = "{}/{}".format(cfg.offline_root, long_filename)
48 if linky != linky_dst:
49         print(__file__, ": symlink path truncated.")
50         exit(False)
51
52 opkgcl.remove("a")