]> git.cworth.org Git - apitrace/commitdiff
Add "apitrace diff-images" command
authorCarl Worth <cworth@cworth.org>
Sat, 12 Nov 2011 00:58:05 +0000 (16:58 -0800)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Wed, 23 Nov 2011 14:18:27 +0000 (14:18 +0000)
Which simply calls out to the existing snapdiff.py script, (notably,
it also passes "apitrace diff-images --help" to snapdiff.py as well).

cli/CMakeLists.txt
cli/cli.hpp
cli/cli_diff_images.cpp [new file with mode: 0644]
cli/cli_main.cpp

index 36a9d2620969296f9d99374311c9a059f61ea1f0..5196467f2494f06f00a31c358cf41bf205b0b592 100644 (file)
@@ -2,6 +2,7 @@ add_executable (apitrace
     cli_main.cpp
     cli_diff.cpp
     cli_diff_state.cpp
+    cli_diff_images.cpp
     cli_dump.cpp
     cli_trace.cpp
 )
index edada5141b4e617c10a96bf65d54d4c5577097bd..1461b4dce61d6f7e6bd211b04d527e2c0eeab1c8 100644 (file)
@@ -42,6 +42,7 @@ struct Command {
 
 extern const Command diff_command;
 extern const Command diff_state_command;
+extern const Command diff_images_command;
 extern const Command dump_command;
 extern const Command trace_command;
 
diff --git a/cli/cli_diff_images.cpp b/cli/cli_diff_images.cpp
new file mode 100644 (file)
index 0000000..390174c
--- /dev/null
@@ -0,0 +1,100 @@
+/*********************************************************************
+ *
+ * Copyright 2011 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+#include <string.h>
+#include <iostream>
+
+#include "cli.hpp"
+#include "os_path.hpp"
+#include "trace_tools.hpp"
+
+static const char *synopsis = "Identify differences between two image dumps.";
+
+static os::Path
+find_command(void)
+{
+#define CLI_DIFF_IMAGES_COMMAND "snapdiff.py"
+
+    return trace::findFile("scripts/" CLI_DIFF_IMAGES_COMMAND,
+     APITRACE_SCRIPTS_INSTALL_DIR "/" CLI_DIFF_IMAGES_COMMAND,
+                           true);
+
+}
+
+static void
+usage(void)
+{
+    char *args[3];
+
+    os::Path command = find_command();
+
+    args[0] = (char *) command.str();
+    args[1] = (char *) "--help";
+    args[2] = NULL;
+
+#ifdef _WIN32
+    std::cerr << "The 'apitrace diff-images' command is not yet supported on this O/S.\n";
+#else
+    execv(command.str(), args);
+#endif
+
+    std::cerr << "Error: Failed to execute " << args[0] << "\n";
+}
+
+static int
+command(int argc, char *argv[])
+{
+    int i;
+    char **args = new char* [argc+2];
+
+    os::Path command = find_command();
+
+    args[0] = (char *) command.str();
+
+    for (i = 0; i < argc; i++) {
+        args[i+1] = argv[i];
+    }
+
+    args[i+1] = NULL;
+
+#ifdef _WIN32
+    std::cerr << "The 'apitrace diff-images' command is not yet supported on this O/S.\n";
+#else
+    execv(command.str(), args);
+#endif
+
+    std::cerr << "Error: Failed to execute " << args[0] << "\n";
+
+    return 1;
+}
+
+const Command diff_images_command = {
+    "diff-images",
+    synopsis,
+    usage,
+    command
+};
index d996abd67c374cb9da95abe28babd39e1eb9b409..fb4f88f845da40603b0428b958a577f290a7085c 100644 (file)
@@ -68,6 +68,7 @@ const Command help_command = {
 static const Command * commands[] = {
     &diff_command,
     &diff_state_command,
+    &diff_images_command,
     &dump_command,
     &trace_command,
     &help_command