]> sourceware.org Git - libabigail.git/commitdiff
Make abipkgdiff compare directories containing binaries
authorDodji Seketeli <dodji@redhat.com>
Sat, 22 Aug 2015 09:44:08 +0000 (11:44 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sat, 22 Aug 2015 10:19:27 +0000 (12:19 +0200)
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 <dodji@redhat.com>
12 files changed:
include/abg-tools-utils.h
src/abg-tools-utils.cc
tests/data/Makefile.am
tests/data/test-diff-pkg/dirpkg-0-dir1/libobj-v0.so [new file with mode: 0755]
tests/data/test-diff-pkg/dirpkg-0-dir1/obj-v0.cc [new file with mode: 0644]
tests/data/test-diff-pkg/dirpkg-0-dir2/libobj-v0.so [new file with mode: 0755]
tests/data/test-diff-pkg/dirpkg-0-dir2/obj-v0.cc [new file with mode: 0644]
tests/data/test-diff-pkg/dirpkg-0-report-0.txt [new file with mode: 0644]
tests/test-diff-pkg.cc
tools/abidiff.cc
tools/abilint.cc
tools/abipkgdiff.cc

index 43f1312f4085556296c2ef9829728de55f69a2b9..94eb3bbad202f529d868a94f24852a5273f9f75e 100644 (file)
@@ -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.
index 4e7e0f7bdfb1488fb59a4bf99cd56da9768a467f..14726ea5aa892c470b477d410fd5aea52f9d2774 100644 (file)
@@ -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();
index 2290cf98ed5088b5aa98505aa7e1cccae89b8710..8155516dfdebad76d40e8e2557a73722e7db6eaf 100644 (file)
@@ -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 (executable)
index 0000000..7373521
Binary files /dev/null and b/tests/data/test-diff-pkg/dirpkg-0-dir1/libobj-v0.so differ
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 (file)
index 0000000..5a016dd
--- /dev/null
@@ -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 (executable)
index 0000000..0032f73
Binary files /dev/null and b/tests/data/test-diff-pkg/dirpkg-0-dir2/libobj-v0.so differ
diff --git a/tests/data/test-diff-pkg/dirpkg-0-dir2/obj-v0.cc b/tests/data/test-diff-pkg/dirpkg-0-dir2/obj-v0.cc
new file mode 100644 (file)
index 0000000..65f6bab
--- /dev/null
@@ -0,0 +1,17 @@
+// Compile with:
+// g++ -g -shared -o libobj-v0.so obj-v0.cc
+
+struct S
+{
+  int  mem0;
+  char mem1;
+
+  S()
+    : mem0(),
+      mem1()
+  {}
+};
+
+void
+bar(S&)
+{}
diff --git a/tests/data/test-diff-pkg/dirpkg-0-report-0.txt b/tests/data/test-diff-pkg/dirpkg-0-report-0.txt
new file mode 100644 (file)
index 0000000..c7c9226
--- /dev/null
@@ -0,0 +1,16 @@
+================ changes of 'libobj-v0.so'===============
+  Functions changes summary: 0 Removed, 1 Changed, 0 Added function
+  Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
+
+  1 function with some indirect sub-type change:
+
+    [C]'function void bar(S&)' has some indirect sub-type changes:
+      parameter 1 of type 'S&' has sub-type changes:
+        in referenced type 'struct S':
+          type size changed from 32 to 64 bits
+          1 data member insertion:
+            'char S::mem1', at offset 32 (in bits)
+
+
+================ end of changes of 'libobj-v0.so'===============
+
index 8cc3af377fbc7912324dd2627f30b70c4bc49cf9..5354999bce375c77acc782098f7bd1e191a5eb55 100644 (file)
@@ -54,6 +54,15 @@ struct InOutSpec
 
 static InOutSpec in_out_specs[] =
 {
+  {
+    "data/test-diff-pkg/dirpkg-0-dir1",
+    "data/test-diff-pkg/dirpkg-0-dir2",
+    "",
+    "",
+    "",
+    "data/test-diff-pkg/dirpkg-0-report-0.txt",
+    "output/test-diff-pkg/dirpkg-0-report-0.txt"
+  },
 #ifdef WITH_RPM
   // Two RPM packages with debuginfo available and have ABI changes
   {
index 9e9221e6b7da330172f2f21faca7545f03d84db3..07c731dd5e9449901e210cb1bdeb9194718b3e6a 100644 (file)
@@ -565,6 +565,8 @@ main(int argc, char* argv[])
           break;
         case abigail::tools_utils::FILE_TYPE_DEB:
           break;
+        case abigail::tools_utils::FILE_TYPE_DIR:
+          break;
         }
 
       switch (t2_type)
@@ -605,6 +607,8 @@ main(int argc, char* argv[])
           break;
         case abigail::tools_utils::FILE_TYPE_DEB:
           break;
+        case abigail::tools_utils::FILE_TYPE_DIR:
+          break;
         }
 
       if (!t1 && !c1)
index 47a797cf4bc956d8988048358d185e27f8196325..33514a81588606ea277bd75459ca1944ae621afb 100644 (file)
@@ -229,6 +229,8 @@ main(int argc, char* argv[])
           break;
         case abigail::tools_utils::FILE_TYPE_DEB:
           break;
+        case abigail::tools_utils::FILE_TYPE_DIR:
+          break;
         }
 
       if (!tu && !corp)
index 7adb0a1d53e8ab8376621e88907b694610e6eb70..ed50eb504c7b6cdc121f519649e1c36663376c1d 100644 (file)
@@ -195,7 +195,10 @@ public:
       is_debug_info_(is_debug_info)
   {
     type_ = guess_file_type(path);
-    extracted_dir_path_ =  extracted_packages_parent_dir() + "/" + dir;
+    if (type_ == abigail::tools_utils::FILE_TYPE_DIR)
+      extracted_dir_path_ = path;
+    else
+      extracted_dir_path_ = extracted_packages_parent_dir() + "/" + dir;
   }
 
   /// Getter of the path of the package.
@@ -300,6 +303,12 @@ public:
   void
   erase_extraction_directory() const
   {
+    if (type() == abigail::tools_utils::FILE_TYPE_DIR)
+      // If we are comparing two directories, do not erase the
+      // directory as it was provided by the user; it's not a
+      // temporary directory we created ourselves.
+      return;
+
     if (verbose)
       cerr << "Erasing temporary extraction directory "
           << extracted_dir_path()
@@ -540,6 +549,12 @@ extract_package(const package& package)
       return false;
 #endif // WITH_DEB
       break;
+
+    case  abigail::tools_utils::FILE_TYPE_DIR:
+      // The input package is just a directory that contains binaries,
+      // there is nothing to extract.
+      break;
+
     default:
       return false;
     }
@@ -1128,6 +1143,14 @@ main(int argc, char* argv[])
        }
       break;
 
+    case abigail::tools_utils::FILE_TYPE_DIR:
+      if (second_package->type() != 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;
This page took 0.052098 seconds and 5 git commands to generate.