]> sourceware.org Git - libabigail.git/commitdiff
Make test-read-dwarf.cc and test-read-write.cc abidiff the ABIs
authorDodji Seketeli <dodji@redhat.com>
Sat, 29 Aug 2015 11:10:25 +0000 (13:10 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sat, 29 Aug 2015 14:23:16 +0000 (16:23 +0200)
use abidiff to compare the ABI of the input ABI against the result of
writing that input back into an XML format.  It should yield the empty
set.  I wonder why I haven't done this since the beginning.  It turned
out we had to fix many things to make it work now.  Just using "GNU
diff" to compare the output against a reference output is definitely
not enough.

* tests/test-read-dwarf.cc (main): Use abidiff to compare the
input elf file with the XML emitted.  That should yield the empty
set.
* tests/test-read-write.cc (main): Likewise, use abidiff to
compare the input abixml file with the one that is emitted.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
tests/test-read-dwarf.cc
tests/test-read-write.cc

index c08768cb749d58e9283bcd9a91c142214cd0de5d..af89b57474ce5e8912168f2769bd69484158fcbb 100644 (file)
@@ -37,6 +37,7 @@
 using std::string;
 using std::ofstream;
 using std::cerr;
+using abigail::tests::get_build_dir;
 
 /// This is an aggregate that specifies where a test shall get its
 /// input from, and where it shall write its ouput to.
@@ -149,8 +150,7 @@ main()
       // programmer likes.
       corp->set_architecture_name("");
 
-      out_abi_path =
-       abigail::tests::get_build_dir() + "/tests/" + s->out_abi_path;
+      out_abi_path = get_build_dir() + "/tests/" + s->out_abi_path;
       if (!abigail::tools_utils::ensure_parent_dir_created(out_abi_path))
        {
          cerr << "Could not create parent director for " << out_abi_path;
@@ -173,10 +173,38 @@ main()
       is_ok = (is_ok && r);
       of.close();
 
+      string abilint = get_build_dir() + "/tools/abilint";
+      abilint += " --noout";
+      string cmd = abilint + " " + out_abi_path;
+      if (system(cmd.c_str()))
+       {
+         cerr << "output file doesn't pass abilint: " << out_abi_path << "\n";
+         r = false;
+       }
+      is_ok = (is_ok && r);
+
+
+      in_elf_path = abigail::tests::get_src_dir() + "/tests/" + s->in_elf_path;
+      string abidiff = get_build_dir() + "/tools/abidiff";
+      cmd = abidiff + " --no-architecture " + in_elf_path + " " + out_abi_path;
+      r = true;
+      if (system(cmd.c_str()))
+       {
+         cerr << "ABIs differ:\n"
+              << in_elf_path
+              << "\nand:\n"
+              << out_abi_path
+              << "\n";
+         r = false;
+       }
+      is_ok = (is_ok && r);
+
       in_abi_path = abigail::tests::get_src_dir() + "/tests/" + s->in_abi_path;
-      string cmd = "diff -u " + in_abi_path + " " + out_abi_path;
+      cmd = "diff -u " + in_abi_path + " " + out_abi_path;
+      r = true;
       if (system(cmd.c_str()))
-       is_ok = false;
+       r = false;
+      is_ok = (is_ok && r);
     }
 
   return !is_ok;
index 99c868ca112ffbf277eca10fc7057d0c06445cf3..32b0420af38f776381e94e5557d53e74714d6b54 100644 (file)
@@ -39,6 +39,7 @@ using std::cerr;
 using abigail::tools_utils::file_type;
 using abigail::tools_utils::check_file;
 using abigail::tools_utils::guess_file_type;
+using abigail::tests::get_build_dir;
 using abigail::translation_unit_sptr;
 using abigail::corpus_sptr;
 using abigail::xml_reader::read_translation_unit_from_file;
@@ -232,9 +233,30 @@ main()
 
       is_ok = (is_ok && r);
       of.close();
-      string cmd = "diff -u " + in_path + " " + out_path;
+      string abilint = get_build_dir() + "/tools/abilint";
+      abilint += " --noout";
+      string cmd = abilint + " " + out_path;
       if (system(cmd.c_str()))
-       is_ok = false;
+       {
+         cerr << "ABI XML file doesn't pass abilint: " << out_path << "\n";
+         is_ok &= false;
+       }
+
+      string abidiff = get_build_dir() + "/tools/abidiff";
+      cmd = abidiff + " --no-architecture " + in_path + " " + out_path;
+      if (system(cmd.c_str()))
+       {
+         cerr << "ABIs differ:\n"
+              << in_path
+              << "\nand:\n"
+              << out_path
+              << "\n";
+         is_ok &= false;
+       }
+
+      cmd = "diff -u " + in_path + " " + out_path;
+      if (system(cmd.c_str()))
+       is_ok &= false;
     }
 
   return !is_ok;
This page took 0.06222 seconds and 5 git commands to generate.