Package portage :: Package tests :: Package lafilefixer :: Module test_lafilefixer
[hide private]

Source Code for Module portage.tests.lafilefixer.test_lafilefixer

  1  # test_lafilefixer.py -- Portage Unit Testing Functionality 
  2  # Copyright 2010 Gentoo Foundation 
  3  # Distributed under the terms of the GNU General Public License v2 
  4   
  5  from portage.tests import TestCase 
  6  from portage.exception import InvalidData 
  7   
8 -class test_lafilefixer(TestCase):
9
10 - def get_test_cases_clean(self):
11 yield b"dlname='libfoo.so.1'\n" + \ 12 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 13 b"old_library='libpdf.a'\n" + \ 14 b"dependency_libs=' -lm'\n" + \ 15 b"current=6\n" + \ 16 b"age=0\n" + \ 17 b"revision=2\n" + \ 18 b"installed=yes\n" + \ 19 b"dlopen=''\n" + \ 20 b"dlpreopen=''\n" + \ 21 b"libdir='/usr/lib64'\n" 22 yield b"dlname='libfoo.so.1'\n" + \ 23 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 24 b"old_library='libpdf.a'\n" + \ 25 b"dependency_libs=' -lm'\n" + \ 26 b"current=6\n" + \ 27 b"age=0\n" + \ 28 b"revision=2\n" + \ 29 b"installed=yes\n" + \ 30 b"dlopen=''\n" + \ 31 b"dlpreopen=''\n" + \ 32 b"libdir='/usr/lib64'\n" 33 yield b"dependency_libs=' liba.la /usr/lib64/bar.la -lc'\n"
34
35 - def get_test_cases_update(self):
36 #.la -> -l* 37 yield b"dlname='libfoo.so.1'\n" + \ 38 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 39 b"old_library='libpdf.a'\n" + \ 40 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libb.la -lc'\n", \ 41 b"dlname='libfoo.so.1'\n" + \ 42 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 43 b"old_library='libpdf.a'\n" + \ 44 b"dependency_libs=' -L/usr/lib64 -la -lb -lc'\n" 45 #move stuff into inherited_linker_flags 46 yield b"dlname='libfoo.so.1'\n" + \ 47 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 48 b"old_library='libpdf.a'\n" + \ 49 b"dependency_libs=' /usr/lib64/liba.la -pthread /usr/lib64/libb.la -lc'\n" + \ 50 b"inherited_linker_flags=''\n", \ 51 b"dlname='libfoo.so.1'\n" + \ 52 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 53 b"old_library='libpdf.a'\n" + \ 54 b"dependency_libs=' -L/usr/lib64 -la -lb -lc'\n" + \ 55 b"inherited_linker_flags=' -pthread'\n" 56 #reorder 57 yield b"dlname='libfoo.so.1'\n" + \ 58 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 59 b"old_library='libpdf.a'\n" + \ 60 b"dependency_libs=' /usr/lib64/liba.la -R/usr/lib64 /usr/lib64/libb.la -lc'\n", \ 61 b"dlname='libfoo.so.1'\n" + \ 62 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 63 b"old_library='libpdf.a'\n" + \ 64 b"dependency_libs=' -R/usr/lib64 -L/usr/lib64 -la -lb -lc'\n" 65 #remove duplicates from dependency_libs (the original version didn't do it for inherited_linker_flags) 66 yield b"dlname='libfoo.so.1'\n" + \ 67 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 68 b"old_library='libpdf.a'\n" + \ 69 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libc.la -pthread -mt" + \ 70 b" -L/usr/lib -R/usr/lib64 -lc /usr/lib64/libb.la -lc'\n" +\ 71 b"inherited_linker_flags=' -pthread -pthread'\n", \ 72 b"dlname='libfoo.so.1'\n" + \ 73 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 74 b"old_library='libpdf.a'\n" + \ 75 b"dependency_libs=' -R/usr/lib64 -L/usr/lib64 -L/usr/lib -la -lc -lb'\n" +\ 76 b"inherited_linker_flags=' -pthread -pthread -mt'\n" 77 #-L rewriting 78 yield b"dependency_libs=' -L/usr/X11R6/lib'\n", \ 79 b"dependency_libs=' -L/usr/lib'\n" 80 yield b"dependency_libs=' -L/usr/local/lib'\n", \ 81 b"dependency_libs=' -L/usr/lib'\n" 82 yield b"dependency_libs=' -L/usr/lib64/pkgconfig/../..'\n", \ 83 b"dependency_libs=' -L/usr'\n" 84 yield b"dependency_libs=' -L/usr/lib/pkgconfig/..'\n", \ 85 b"dependency_libs=' -L/usr/lib'\n" 86 yield b"dependency_libs=' -L/usr/lib/pkgconfig/../.. -L/usr/lib/pkgconfig/..'\n", \ 87 b"dependency_libs=' -L/usr -L/usr/lib'\n" 88 #we once got a backtrace on this one 89 yield b"dependency_libs=' /usr/lib64/libMagickCore.la -L/usr/lib64 -llcms2 /usr/lib64/libtiff.la " + \ 90 b"-ljbig -lc /usr/lib64/libfreetype.la /usr/lib64/libjpeg.la /usr/lib64/libXext.la " + \ 91 b"/usr/lib64/libXt.la /usr/lib64/libSM.la -lICE -luuid /usr/lib64/libICE.la /usr/lib64/libX11.la " + \ 92 b"/usr/lib64/libxcb.la /usr/lib64/libXau.la /usr/lib64/libXdmcp.la -lbz2 -lz -lm " + \ 93 b"/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4/libgomp.la -lrt -lpthread /usr/lib64/libltdl.la -ldl " + \ 94 b"/usr/lib64/libfpx.la -lstdc++'", \ 95 b"dependency_libs=' -L/usr/lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.4 -lMagickCore -llcms2 " + \ 96 b"-ltiff -ljbig -lc -lfreetype -ljpeg -lXext -lXt -lSM -lICE -luuid -lX11 -lxcb -lXau -lXdmcp " + \ 97 b"-lbz2 -lz -lm -lgomp -lrt -lpthread -lltdl -ldl -lfpx -lstdc++'"
98 99
100 - def get_test_cases_broken(self):
101 yield b"" 102 #no dependency_libs 103 yield b"dlname='libfoo.so.1'\n" + \ 104 b"current=6\n" + \ 105 b"age=0\n" + \ 106 b"revision=2\n" 107 #borken dependency_libs 108 yield b"dlname='libfoo.so.1'\n" + \ 109 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 110 b"old_library='libpdf.a'\n" + \ 111 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libb.la -lc' \n" 112 #borken dependency_libs 113 yield b"dlname='libfoo.so.1'\n" + \ 114 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 115 b"old_library='libpdf.a'\n" + \ 116 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libb.la -lc\n" 117 #crap in dependency_libs 118 yield b"dlname='libfoo.so.1'\n" + \ 119 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 120 b"old_library='libpdf.a'\n" + \ 121 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libb.la -lc /-lstdc++'\n" 122 #dependency_libs twice 123 yield b"dlname='libfoo.so.1'\n" + \ 124 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 125 b"old_library='libpdf.a'\n" + \ 126 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libb.la -lc /-lstdc++'\n" +\ 127 b"dependency_libs=' /usr/lib64/liba.la /usr/lib64/libb.la -lc /-lstdc++'\n" 128 #inherited_linker_flags twice 129 yield b"dlname='libfoo.so.1'\n" + \ 130 b"library_names='libfoo.so.1.0.2 libfoo.so.1 libfoo.so'\n" + \ 131 b"old_library='libpdf.a'\n" + \ 132 b"inherited_linker_flags=''\n" +\ 133 b"inherited_linker_flags=''\n"
134
135 - def testlafilefixer(self):
136 from portage.util.lafilefixer import _parse_lafile_contents, rewrite_lafile 137 138 for clean_contents in self.get_test_cases_clean(): 139 self.assertEqual(rewrite_lafile(clean_contents), (False, None)) 140 141 for original_contents, fixed_contents in self.get_test_cases_update(): 142 self.assertEqual(rewrite_lafile(original_contents), (True, fixed_contents)) 143 144 for broken_contents in self.get_test_cases_broken(): 145 self.assertRaises(InvalidData, rewrite_lafile, broken_contents)
146