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

[Xen-devel] [PATCH OSSTEST v2 1/2] standalone: refactor out some useful bits of standalone-reset



I sometimes want just these bits.

I went with a new "sa" prefix, but I left standalone-reset alone since it is
already reasonably well known.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
v2: correct usage and argument parsing
---
 README           |  3 +++
 sa-forget-flight | 39 +++++++++++++++++++++++++++++++++++++++
 sa-init-db       | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 standalone-reset | 30 ++----------------------------
 4 files changed, 100 insertions(+), 28 deletions(-)
 create mode 100755 sa-forget-flight
 create mode 100755 sa-init-db

diff --git a/README b/README
index a4d5aac..9a85549 100644
--- a/README
+++ b/README
@@ -158,6 +158,9 @@ sg-*:   ?
 
 ts-*:   Test Step scripts.
 
+sa-*:  Standalone mode.
+
+
 Jobs
 ====
 
diff --git a/sa-forget-flight b/sa-forget-flight
new file mode 100755
index 0000000..8b005f1
--- /dev/null
+++ b/sa-forget-flight
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2014 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+usage(){
+       cat <<END
+usage: ./sa-forget-flight <database> <flight>
+END
+}
+
+if [ $# -ne 2 ] ; then
+       usage >&2
+       exit 1
+fi
+
+db="$1"
+flight="$2"
+
+sqlite3 "$db" <<END
+       DELETE FROM runvars WHERE flight='$flight';
+       DELETE FROM jobs    WHERE flight='$flight';
+       DELETE FROM flights WHERE flight='$flight';
+END
diff --git a/sa-init-db b/sa-init-db
new file mode 100755
index 0000000..37ab4be
--- /dev/null
+++ b/sa-init-db
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2014 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+usage(){
+       cat <<END
+usage: ./sa-init-db [database]
+END
+}
+
+if [ $# -ne 1 ] ; then
+       usage >&2
+       exit 1
+fi
+
+db="$1"
+
+sqlite3 "$db" <<END
+       CREATE TABLE flights (
+               flight TEXT PRIMARY KEY,
+               blessing TEXT,
+               intended TEXT,
+               branch TEXT
+               );
+       CREATE TABLE jobs (
+               flight TEXT NOT NULL,
+               job TEXT NOT NULL,
+               recipe TEXT NOT NULL,
+               status TEXT NOT NULL,
+               PRIMARY KEY(flight,job)
+               );
+       CREATE TABLE runvars (
+               flight TEXT NOT NULL,
+               job TEXT NOT NULL,
+               name TEXT NOT NULL,
+               val TEXT NOT NULL,
+               synth BOOLEAN NOT NULL,
+               PRIMARY KEY(flight,job,name)
+               );
+END
diff --git a/standalone-reset b/standalone-reset
index e978b6b..09c0269 100755
--- a/standalone-reset
+++ b/standalone-reset
@@ -131,35 +131,9 @@ case $# in
 esac
 
 if test -f standalone.db; then
-       sqlite3 standalone.db <<END
-               DELETE FROM runvars WHERE flight='$flight';
-               DELETE FROM jobs    WHERE flight='$flight';
-               DELETE FROM flights WHERE flight='$flight';
-END
+       ./sa-forget-flight standalone.db "$flight"
 else
-       sqlite3 standalone.db <<END
-               CREATE TABLE flights (
-                       flight TEXT PRIMARY KEY,
-                       blessing TEXT,
-                       intended TEXT,
-                       branch TEXT
-                       );
-               CREATE TABLE jobs (
-                       flight TEXT NOT NULL,
-                       job TEXT NOT NULL,
-                       recipe TEXT NOT NULL,
-                       status TEXT NOT NULL,
-                       PRIMARY KEY(flight,job)
-                       );
-               CREATE TABLE runvars (
-                       flight TEXT NOT NULL,
-                       job TEXT NOT NULL,
-                       name TEXT NOT NULL,
-                       val TEXT NOT NULL,
-                       synth BOOLEAN NOT NULL,
-                       PRIMARY KEY(flight,job,name)
-                       );
-END
+       ./sa-db-init standalone.db
 fi
 
 : ${BUILD_LVEXTEND_MAX:=50}
-- 
1.8.5.2


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.