powerguru-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Powerguru-commit] [SCM] powerguru branch, master, updated. ea4f0556a9c4


From: Rob Savoye
Subject: [Powerguru-commit] [SCM] powerguru branch, master, updated. ea4f0556a9c4638f9102ba36a08100f2a1f52dfd
Date: Sun, 9 Dec 2018 14:14:07 -0500 (EST)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "powerguru".

The branch, master has been updated
       via  ea4f0556a9c4638f9102ba36a08100f2a1f52dfd (commit)
      from  d8857803a3001ec7b1fc78edc0681191ac22b461 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/powerguru.git/commit/?id=ea4f0556a9c4638f9102ba36a08100f2a1f52dfd


commit ea4f0556a9c4638f9102ba36a08100f2a1f52dfd
Author: Rob Savoye <address@hidden>
Date:   Sun Dec 9 12:14:02 2018 -0700

    New code and test case for procesing internal XML commands between client 
and server.

diff --git a/lib/commands.cc b/lib/commands.cc
new file mode 100644
index 0000000..c570a29
--- /dev/null
+++ b/lib/commands.cc
@@ -0,0 +1,81 @@
+// 
+// Copyright (C) 2018
+//      Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+// This is generated by autoconf
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <unistd.h>
+#include <cstring>
+#include <vector>
+#include "xml.h"
+#include "log.h"
+#include "commands.h"
+
+extern LogFile dbglogfile;
+
+Commands::Commands()
+{
+    DEBUGLOG_REPORT_FUNCTION;
+}
+
+Commands::~Commands()
+{
+    DEBUGLOG_REPORT_FUNCTION;
+}
+
+std::string &
+Commands::createCommand(cmd_t cmd, const std::string &args,
+                        std::string &str)
+{
+    DEBUGLOG_REPORT_FUNCTION;
+    str.clear();
+    str = "<command>";
+    switch (cmd) {
+      case LIST:
+          dbglogfile << "LIST command" << std::endl;
+          str += "<list>" + args + "</list>";
+          break;
+      case POLL:
+          dbglogfile << "POLL command" << std::endl;  
+          str += "<poll>" + args + "</poll>";
+          break;
+      case NOP:
+          dbglogfile << "NOP command" << std::endl;  
+          break;
+    };
+    
+    str += "</command>";
+
+    return str;
+}
+
+const std::string &
+parseCommand(XML &xml)
+{
+    DEBUGLOG_REPORT_FUNCTION;
+}
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:
diff --git a/lib/commands.h b/lib/commands.h
new file mode 100644
index 0000000..f714ecf
--- /dev/null
+++ b/lib/commands.h
@@ -0,0 +1,50 @@
+// 
+// Copyright (C) 2018
+//      Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+#ifndef __COMMANDS_H__
+#define __COMMANDS_H__
+
+// This is generated by autoconf
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <cstring>
+#include <vector>
+#include <map>
+#include "xml.h"
+#include "log.h"
+
+class Commands 
+{
+ public:
+  typedef enum { NOP, LIST, POLL } cmd_t; 
+  Commands();
+  ~Commands();
+
+  std::string &createCommand(cmd_t cmd, const std::string &args,
+                                   std::string &str);
+  const std::string &execCommand(XML &xml);
+};
+
+#endif // __COMMANDS_H__
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: nil
+// End:
diff --git a/testsuite/libtests/cmd-test.cc b/testsuite/libtests/cmd-test.cc
new file mode 100644
index 0000000..db96a86
--- /dev/null
+++ b/testsuite/libtests/cmd-test.cc
@@ -0,0 +1,138 @@
+// 
+//   Copyright (C) 2018 Free Software Foundation, Inc.
+//
+//   This program is free software; you can redistribute it and/or modify
+//   it under the terms of the GNU General Public License as published by
+//   the Free Software Foundation; either version 2 of the License, or
+//   (at your option) any later version.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU General Public License for more details.
+//
+//   You should have received a copy of the GNU General Public License
+//   along with this program; if not, write to the Free Software
+//   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+//
+
+// This is generated by autoconf
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <unistd.h>
+#include <vector>
+#include "dejagnu.h"
+#include "xml.h"
+#include "commands.h"
+
+int verbosity;
+static void usage (void);
+bool waitforgdb = false;
+
+TestState runtest;
+
+class Test : public Commands
+{
+public:
+    Test() {
+        DEBUGLOG_REPORT_FUNCTION;
+
+        std::string str;
+        std::cerr << createCommand(Commands::NOP, "", str) << std::endl;
+        if (str == "<command></command>") {
+            runtest.pass("NOP command");
+        } else {
+            runtest.fail("NOP command");
+        }
+        str.erase();
+        //
+        std::cerr << createCommand(Commands::LIST, "foo", str) << std::endl;
+        if (str == "<command><list>foo</list></command>") {
+            runtest.pass("LIST command");
+        } else {
+            runtest.fail("LIST command");
+        }
+        str.erase();
+        std::cerr << createCommand(Commands::POLL, "bar", str) << std::endl;
+        if (str == "<command><poll>bar</poll></command>") {
+            runtest.pass("POLL command");
+        } else {
+            runtest.fail("POLL command");
+        }
+        str.erase();
+
+        
+    };
+    ~Test() {};
+};
+
+int
+main(int argc, char *argv[])
+{
+    int c;
+    bool dump = false;
+    char buffer[300];
+    std::string filespec;
+    
+    int retries = 3;
+
+    memset(buffer, 0, 300);
+    
+    while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
+        switch (c) {
+          case 'h':
+            usage ();
+            break;
+            
+          case 'd':
+            dump = true;
+            break;
+            
+          case 's':
+            waitforgdb = true;
+            break;
+                                                                               
 
+          case 'v':
+            verbosity++;
+            break;
+            
+          default:
+            usage ();
+            break;
+        }
+    }
+    
+    // get the file name from the command line
+    if (optind < argc) {
+        filespec = argv[optind];
+        std::cout << "Will use \"" << filespec << "\" for test " << std::endl;
+    }
+
+    Test test;
+}
+
+void
+cntrlc_handler (int sig)
+{
+    std::cerr << "Got a ^C !" << std::endl;
+}
+
+void
+alarm_handler (int sig)
+{
+    std::cerr << "Got an alarm signal !" << std::endl;
+    std::cerr << "This is OK, we use it to end this test case." << std::endl;
+}
+
+static void
+usage (void)
+{
+    std::cerr << "This program tests the XML processing code." << std::endl;
+    std::cerr << "Usage: ./xml [h]" << std::endl;
+    std::cerr << "-h\tHelp" << std::endl;
+    std::cerr << "-d\tDump parsed data" << std::endl;
+    exit (-1);
+}
+

-----------------------------------------------------------------------

Summary of changes:
 lib/commands.cc                |  81 ++++++++++++++++++++++++
 lib/{gdb.h => commands.h}      |  30 +++++++--
 testsuite/libtests/cmd-test.cc | 138 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 244 insertions(+), 5 deletions(-)
 create mode 100644 lib/commands.cc
 copy lib/{gdb.h => commands.h} (62%)
 create mode 100644 testsuite/libtests/cmd-test.cc


hooks/post-receive
-- 
powerguru



reply via email to

[Prev in Thread] Current Thread [Next in Thread]