gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r18195 - in gnunet-update: bin gnunet_update test


From: gnunet
Subject: [GNUnet-SVN] r18195 - in gnunet-update: bin gnunet_update test
Date: Thu, 17 Nov 2011 19:16:59 +0100

Author: harsha
Date: 2011-11-17 19:16:59 +0100 (Thu, 17 Nov 2011)
New Revision: 18195

Added:
   gnunet-update/test/package.sh
   gnunet-update/test/test_metadata.py
Modified:
   gnunet-update/bin/gnunet-update
   gnunet-update/gnunet_update/dependency.py
   gnunet-update/gnunet_update/package.py
Log:
added unit test case for metadata and intergration test case for packaging and 
installation

Modified: gnunet-update/bin/gnunet-update
===================================================================
--- gnunet-update/bin/gnunet-update     2011-11-17 18:04:31 UTC (rev 18194)
+++ gnunet-update/bin/gnunet-update     2011-11-17 18:16:59 UTC (rev 18195)
@@ -49,4 +49,5 @@
 fi
 
 export GNUNET_UPDATE_HOME=$GNUNET_UPDATE_HOME
-$PYTHON $GNUNET_UPDATE_HOME/gnunet_update $@
\ No newline at end of file
+$PYTHON $GNUNET_UPDATE_HOME/gnunet_update $@
+exit $?
\ No newline at end of file

Modified: gnunet-update/gnunet_update/dependency.py
===================================================================
--- gnunet-update/gnunet_update/dependency.py   2011-11-17 18:04:31 UTC (rev 
18194)
+++ gnunet-update/gnunet_update/dependency.py   2011-11-17 18:16:59 UTC (rev 
18195)
@@ -22,6 +22,8 @@
 #                                     
 #                                                                   
 #File for holding the Dependency and BinaryObject classes
+#
+#FIXME: No convention being followed for private members!!
 
 import os
 from operator import xor
@@ -40,8 +42,13 @@
         self.name = name
         self.path = path
         if path is not None:
-            self.realname = os.path.basename(os.path.realpath(path))
+            self.set_path(path)
             self.hash = util.sha512_hexdigest(path)
+
+    def set_path(self, path):
+        """Setter for path."""
+        self.path = path
+        self.realname = os.path.basename(os.path.realpath(path))
     
     def __eq__(self, other):
         """Compares two dependency objects. Returns True if both have same name
@@ -57,7 +64,7 @@
 class BinaryObject:
     """Class representing executable code."""
     
-    def __init__(self, path=None, name=None):
+    def __init__(self, name=None, path=None):
         """Returns am instance of BinaryObject."""
         self.name = name
         self.path = path
@@ -82,3 +89,13 @@
     def dependency_listlines(self):
         """Return list of lines which describe all dependencies."""
         return map(self._dependency_ascii, self._deps)
+
+    def __eq__(self, other):
+        """The equality relation."""
+        if not (self.name == other.name and self.path == other.path):
+            return False
+        
+        for dep in other.get_dependencies():
+            if dep not in self._deps:
+                return False
+        return True

Modified: gnunet-update/gnunet_update/package.py
===================================================================
--- gnunet-update/gnunet_update/package.py      2011-11-17 18:04:31 UTC (rev 
18194)
+++ gnunet-update/gnunet_update/package.py      2011-11-17 18:16:59 UTC (rev 
18195)
@@ -133,8 +133,8 @@
             if 0 != proc.returncode:
                 continue
             #create a new BinaryObject instance and collect its dependencies
-            bin_object = BinaryObject(file_path, 
-                                      root[len(install_dir) + 1:] + '/' + file 
)
+            bin_object = BinaryObject(root[len(install_dir) + 1:] + '/' + file,
+                                      file_path)
             
             for dep_data in util.parse_ldd_output(proc_stdout):
                 #we cannot find a library without its location

Added: gnunet-update/test/package.sh
===================================================================
--- gnunet-update/test/package.sh                               (rev 0)
+++ gnunet-update/test/package.sh       2011-11-17 18:16:59 UTC (rev 18195)
@@ -0,0 +1,46 @@
+#!/bin/bash
+# This file is part of GNUnet.
+# (C) 2001--2011 Christian Grothoff (and other contributing authors)
+#
+# GNUnet 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, or (at your
+# option) any later version.
+#
+# GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+#File:     bin/gnunet-update
+#Author:   Sree Harsha Totakura
+#
+# File to test packaging functionality
+
+if [ ! -n "$GNUNET_UPDATE_HOME" ] #Do our best to find GNUNET_UPDATE_HOME
+then
+       #Find relative path based on the location of this executable
+       EXEC_NAME=$0
+       
+       #check if we are a running from a symbolic link
+       if [ -L $EXEC_NAME ]
+       then
+               #Follow the symbolic link
+               REAL_EXEC=`readlink -f $EXEC_NAME`
+               $REAL_EXEC $@
+               exit $?
+       elif [ ${EXEC_NAME:0:1} == '/' ] # Absolute path
+       then
+               GNUNET_UPDATE_HOME=$(dirname ${EXEC_NAME})/../
+       else #our last hope before we fail
+               GNUNET_UPDATE_HOME=$(dirname ${EXEC_NAME})/../
+       fi
+fi
+
+cd $GNUNET_UPDATE_HOME; bin/gnunet-update package test/old/test-package 
/tmp/test-pack && \
+ bin/gnunet-update install /tmp/test-pack.meta /tmp/test-pack.tgz 
/tmp/test-install


Property changes on: gnunet-update/test/package.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: gnunet-update/test/test_metadata.py
===================================================================
--- gnunet-update/test/test_metadata.py                         (rev 0)
+++ gnunet-update/test/test_metadata.py 2011-11-17 18:16:59 UTC (rev 18195)
@@ -0,0 +1,101 @@
+# This file is part of GNUnet.
+# (C) 2001--2011 Christian Grothoff (and other contributing authors)
+#
+# GNUnet 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, or (at your
+# option) any later version.
+#
+# GNUnet 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 GNUnet; see the file COPYING.  If not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+#File:     test/test_metadata.py
+#Author:   Sree Harsha Totakura
+#
+
+"""Test case file for metadata file utility."""
+
+
+import unittest
+import os
+import tempfile
+import platform
+
+import __init__
+from gnunet_update.metadata import Metadata
+from gnunet_update.dependency import BinaryObject, Dependency
+
+class TestMetadata(unittest.TestCase):
+    """Metadata test case class."""
+    deps_1 = list()
+    deps_2 = list()
+    binary_objects = list()
+
+    deps_1.append(Dependency("dep1_1"))
+    deps_1.append(Dependency("dep1_2"))
+    deps_1[0].set_path("/tmp/dependencies/dep1_1.so.1.0.0")
+    deps_1[0].hash = "hash-dep_1_0"
+    deps_1[1].set_path("/tmp/dependencies/dep1_2.so.1.1.0")
+    deps_1[1].hash = "hash-dep_1_1"
+    
+    deps_2.append(Dependency("dep2_1"))
+    deps_2[-1].set_path("/tmp/dependencies/dep2_1.so.1.0.0")
+    deps_2[-1].hash = "hash-dep_2_1"
+    deps_2.append(Dependency("dep2_2"))
+    deps_2[-1].set_path("/tmp/dependencies/dep2_2.so.1.1.0")
+    deps_2[-1].hash = "hash-dep_2_2"
+    
+    binary_objects.append(BinaryObject("test-binary1"))
+    for dep in deps_1:
+        binary_objects[-1].add_dependency(dep)
+    binary_objects[-1].hash = "hash-binary_object_1"
+    
+    binary_objects.append(BinaryObject("test-binary2"))
+    for dep in deps_2:
+        binary_objects[-1].add_dependency(dep)
+    binary_objects[-1].hash = "hash-binary_object_2"
+
+
+    def test_metadata_read_write(self):
+        """Test case to test metadata file writing."""
+
+        machine = platform.machine()
+        system = platform.system()
+        pkey = 'ABCDEFGHIJK012345678' # A testing key
+        release = 'R-A001'
+        metadata = Metadata(machine=machine, system=system,
+                            pkey=pkey, release=release)
+        
+        metadata.binary_objects = self.binary_objects
+        metadata.dependencies = self.deps_1 + self.deps_2
+
+        # Write the metadata to file
+        metadata_file = metadata.write_to_file()
+        print metadata_file
+        del metadata
+        
+        metadata = Metadata()
+        # read the metadata file
+        metadata.read_from_file(metadata_file)
+        # FIXME: More relevant assertion functions added in python 2.7. Update
+        # to them when relevant
+        self.assertEquals(machine, metadata.machine)
+        self.assertEquals(system, metadata.system)
+        self.assertEquals(pkey, metadata.pkey)
+        self.assertEquals(release, metadata.release)
+        for binary_object in self.binary_objects:
+            self.assertTrue(binary_object in metadata.binary_objects)
+        for dep in self.deps_1 + self.deps_2:
+            self.assertTrue(dep in metadata.dependencies)
+        
+        os.remove(metadata_file)
+
+if __name__ == '__main__':
+    unittest.main()


Property changes on: gnunet-update/test/test_metadata.py
___________________________________________________________________
Added: svn:executable
   + *




reply via email to

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