From d7dbbf0d50d9953033a99a77d0dd039ab1129fdf Mon Sep 17 00:00:00 2001 From: Dodji Seketeli Date: Sat, 22 Aug 2015 11:44:08 +0200 Subject: [PATCH] Make abipkgdiff compare directories containing binaries abipkgdiff knows how to compare the ABI of binaries contained in .deb and .rpm files. This patch adds support for comparing the ABI of binaries contained in two directories. * include/abg-tools-utils.h (enum file_type): Add a new FILE_TYPE_DIR enumerator. * src/abg-tools-utils.cc (operator<<(ostream&, file_type)): Support serialization of the new FILE_TYPE_DIR enumerator. (guess_file_type): Detect that the path given is a directory. * tools/abipkgdiff.cc (package::package): If the package is a directory, then set its extracted directory path to the path of the directory. (package::erase_extraction_directory): Do not erase the extraction directory if the package is a directory provided by the user. (extract_package): If the package is a directory provided by the user, then there is nothing to extract. (main): If the first package is a directory, then the second one should be a directory as well. * tools/abidiff.cc (main): Support directories as input. * tools/abilint.cc (main): Likewise. * tests/data/test-diff-pkg/dirpkg-0-dir{1,2}/libobj-v0.so: New binary test inputs. * test/data/test-diff-pkg/dirpkg-0-report-0.txt: New input test file. * tests/data/test-diff-pkg/dirpkg-1-dir{1,2}/obj-v0.cc: Source code of the binary test inputs above. * tests/data/Makefile.am: Add the new files above to the source distribution. * tests/test-diff-pkg.cc (in_out_specs): Add the new test input files above to the set of tests this harness has to run over. Signed-off-by: Dodji Seketeli --- include/abg-tools-utils.h | 2 ++ src/abg-tools-utils.cc | 6 +++++ tests/data/Makefile.am | 7 ++++- .../test-diff-pkg/dirpkg-0-dir1/libobj-v0.so | Bin 0 -> 8951 bytes .../test-diff-pkg/dirpkg-0-dir1/obj-v0.cc | 15 +++++++++++ .../test-diff-pkg/dirpkg-0-dir2/libobj-v0.so | Bin 0 -> 8991 bytes .../test-diff-pkg/dirpkg-0-dir2/obj-v0.cc | 17 ++++++++++++ .../data/test-diff-pkg/dirpkg-0-report-0.txt | 16 +++++++++++ tests/test-diff-pkg.cc | 9 +++++++ tools/abidiff.cc | 4 +++ tools/abilint.cc | 2 ++ tools/abipkgdiff.cc | 25 +++++++++++++++++- 12 files changed, 101 insertions(+), 2 deletions(-) create mode 100755 tests/data/test-diff-pkg/dirpkg-0-dir1/libobj-v0.so create mode 100644 tests/data/test-diff-pkg/dirpkg-0-dir1/obj-v0.cc create mode 100755 tests/data/test-diff-pkg/dirpkg-0-dir2/libobj-v0.so create mode 100644 tests/data/test-diff-pkg/dirpkg-0-dir2/obj-v0.cc create mode 100644 tests/data/test-diff-pkg/dirpkg-0-report-0.txt diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h index 43f1312f..94eb3bba 100644 --- a/include/abg-tools-utils.h +++ b/include/abg-tools-utils.h @@ -117,6 +117,8 @@ enum file_type FILE_TYPE_SRPM, /// An DEB (.deb) binary file FILE_TYPE_DEB, + /// A plain directory + FILE_TYPE_DIR }; /// Exit status for abidiff and abicompat tools. diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 4e7e0f7b..14726ea5 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -474,6 +474,9 @@ operator<<(ostream& output, case FILE_TYPE_DEB: repr = "Debian binary file type"; break; + case FILE_TYPE_DIR: + repr = "Directory type"; + break; } output << repr; @@ -578,6 +581,9 @@ guess_file_type(istream& in) file_type guess_file_type(const string& file_path) { + if (is_dir(file_path)) + return FILE_TYPE_DIR; + ifstream in(file_path.c_str(), ifstream::binary); file_type r = guess_file_type(in); in.close(); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 2290cf98..8155516d 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -831,4 +831,9 @@ test-diff-pkg/libsigc++-2.0-0c2a-dbgsym_2.4.0-1_amd64.ddeb \ test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64--libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64-report-0.txt \ test-diff-pkg/libsigc++-2.0-0c2a_2.4.0-1_amd64.deb \ test-diff-pkg/libsigc++-2.0-0v5-dbgsym_2.4.1-1ubuntu2_amd64.ddeb \ -test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb +test-diff-pkg/libsigc++-2.0-0v5_2.4.1-1ubuntu2_amd64.deb \ +test-diff-pkg/dirpkg-0-dir1/libobj-v0.so \ +test-diff-pkg/dirpkg-0-dir2/libobj-v0.so \ +test-diff-pkg/dirpkg-0-report-0.txt \ +test-diff-pkg/dirpkg-0-dir1/obj-v0.cc \ +test-diff-pkg/dirpkg-0-dir2/obj-v0.cc diff --git a/tests/data/test-diff-pkg/dirpkg-0-dir1/libobj-v0.so b/tests/data/test-diff-pkg/dirpkg-0-dir1/libobj-v0.so new file mode 100755 index 0000000000000000000000000000000000000000..7373521ef7c791bf631ef74c0fb45ba841aa46b4 GIT binary patch literal 8951 zcmeHMYit}>6~43M$2x1TH+B+YyC_4O1gD9|cATariIa64JL}-2)N#}{$ePUVjCVKe zBh1XEc2#IZ(u#mWLy(}A5I>NJ0Er3&B2XdWHdT}#NH{>G2q9rnRdQ%0k^+@^#hi2J zp7rePZc_;ae|%Om=brDL@4n{leLgolHWH8|Mk2Gl46WH(7m139xmFPX6=nUb9^MN3 zF!vR%%MPBfwqH>Ol{HnD}zi1EAqB^{8 zYak05o`Xk@u~&LGz0le5-rqZJ-27MH8#jKx?b^0~VhJ!FKMA$}=VukErY72k*eZA$ z;rUtTy=Py2^U||J!#Cf#_30-c`00ha;kSSNr!YjlugI){rF@+M^HD0W^eQ;EV0y55nV@0st*6#J(*)0@e-XDm)Rkj`c(oG>h_m2u0Xh*6G8qaC}`E9s#_iLVee9 zypjFL|M4{~na$@k+tDpY)0mddr5&bCfnwU|#9_@aEi;+69n+dPJe0}j%n3c7G2OVz zFA>Vw z$gl<@A;Whkm*z1&@b7i~ANKgawkXHWzaD$-kNaZMT$Q00LW z;K-cKP&kdJKkKv~1O6d^A+4pk$=gpr0?ixFp#SZU^DxgQcK$PqlUJuM^0pLBCw0iX zam>JPFn4ch3CD>Apqv1Wf@30z^vpPurXx~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2Q~^mGX~%#7*srFGHW{I#qegP&%5=y)H70cJ#k0#pU9Ds}!$cG@q8@ zwT$M;QoN4Q{8x(C7w5N9JjiIiD#gq1moQ$2nT+O_QvXo#99mI!`CeqI3Wu5}M<9c{^ZqrF4GB{mc8qy8@^BA|K@*JW_>z7=nUI75d>Cz!fC= z3vRVRfbZtf#xgJQm#&k?W-PzaI4=Go0;+Mznb`!2<9czZU8&so^&CUSDWAWSO64&M90!XW&)!fv1iP j9v&S6kJ78|N;lL0wTtg))O#hpeB)hqb4@qed~5%2At@;U literal 0 HcmV?d00001 diff --git a/tests/data/test-diff-pkg/dirpkg-0-dir1/obj-v0.cc b/tests/data/test-diff-pkg/dirpkg-0-dir1/obj-v0.cc new file mode 100644 index 00000000..5a016dd6 --- /dev/null +++ b/tests/data/test-diff-pkg/dirpkg-0-dir1/obj-v0.cc @@ -0,0 +1,15 @@ +// Compile with: +// g++ -g -shared -o libobj-v0.so obj-v0.cc + +struct S +{ + int mem0; + + S() + : mem0() + {} +}; + +void +bar(S&) +{} diff --git a/tests/data/test-diff-pkg/dirpkg-0-dir2/libobj-v0.so b/tests/data/test-diff-pkg/dirpkg-0-dir2/libobj-v0.so new file mode 100755 index 0000000000000000000000000000000000000000..0032f73fb7c5b6cfbcb254c896089d10962a826d GIT binary patch literal 8991 zcmeHMYiwLc6`s56$2#k**LEB7C}e4q;57K!PSVsQabm}DvJOs49Y;-zted;L*Sj0` zVRo-mrz$ieX+=PR&>zrBg&$QL0Y4B3L`nt1Z6JyS66R4ULj7S;RdS$Glk$)eQp|Ve z&RO5RyW3O(!5`0R=gj%$d~@c`ojcE`hDHwfG)-{ui#>w0nR*B5R~ZZKDgn_idPO7R zi1@IyRi;Y@uGIcUM`0^m+@S1Ok}ZW#y=^BbJwr~b$a@@Euw>rD;3h2 zN?9yun&OC9gFUj2ICWKZj{H;s?{viQsk`>6($Pp^dA|BEvbt*)+r4Ph(r zZ^r+p9k-u+^{r>092|P%o$H@He$P)X+zS2W_wR;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1+l!0t5(LM0#SP%eIPkv5U5cGTBLBCo)+p04Z#BZ9dU!B7{q* z_MwJ7R)vn#KQIRJxXj}|%iYS7$44H2xqx0IXv}9m&kHPj)xb-B$%gs(aAfF5Ol32l z=NXnfuSjD=JdU#-MS{k7=JUADlIJ_FKijdy37w!hgLR%aSVoj1sz3SW`YTu@kl<${ zjOQtqGXx^Af9CV^=aA>-^SsBB=SkwzTceeM||4WL`@6UTa%{&)n5gd-XHg`>*{>&`Um9y z+{5Q}>f8t9{~CO1GWO5w7`_+aafII+*Pr{(8y^3Bj(D9K1);+crI`6F|A-v-^9!}k zk zC0hU$7&6Z(J}=?e-fP=jgWuWeFuuh^CB6K$HTb_${5^NzZ&G~kb2ha(#GlpRb3Mon zzdN_-RmJaNLzU@KW!v%C;pQ)>jnkwW57#5J3xDnpJbu&oRLy_tqfTj;Jq|spV^kyd zqjo%>yG{Ijlq~<#>bO`L7&rEX{A_ctG%cRgPEQLs7mT zGa1h><@UkSeP=mdNIUW`~?v~@Ng2&TxyiM>pS&p~k zJ~ZNnWZI8iE{|*OOh4|qO5>F)!;gD09*0~o+KqR|Zj{=Sd!rZU(*Q5-T@^U_e!-^& zUVHB>>Wn#c;?`ohrE_noiOP1Pn)t9%>#Im#ozHCOxa_e48R z4THY-Jzh}d@VN|B8JS22>8%+7Wb zSGacJv~V`4iK%S%G$<}j-b$C5E*%^g#(~j+!$Zctype() != abigail::tools_utils::FILE_TYPE_DIR) + { + cerr << opts.package2 << " should be a directory\n"; + return 1; + } + break; + default: cerr << opts.package1 << " should be a valid package file \n"; return 1; -- 2.43.5