hal/hald Makefile.am, 1.43, 1.44 hald_dbus.c, 1.22, 1.23 hald_test_libhal.c, 1.3, 1.4

David Zeuthen david at freedesktop.org
Wed Feb 16 10:39:58 PST 2005


Update of /cvs/hal/hal/hald
In directory gabe:/tmp/cvs-serv27614/hald

Modified Files:
	Makefile.am hald_dbus.c hald_test_libhal.c 
Log Message:
2005-02-16  David Zeuthen  <davidz at redhat.com>

	* tools/device-manager/DeviceManager.py:
	(DeviceManager.update_tab_advanced): Make this work for string lists

	* tools/lshal.c (main): Various cleanups

	* libhal/libhal.c (libhal_property_fill_value_from_variant): Make
	this one static. Make sure to recurse into string array otherwise
	it won't work at all
	(libhal_get_string_array_from_iter): Make this static. Take
	num_elems pointer
	(libhal_property_set_get_num_elems): New function
	(libhal_get_all_devices): Pass num_devices to
	libhal_get_string_array_from_iter
	(libhal_ctx_shutdown): Remove match and filter function
	(libhal_ctx_free): Implement this one; free our context

	* libhal/libhal.h: Add prototype for libhal_property_set_get_num_elems

	* hald/hald_test_libhal.c (check_libhal): Add tests for the property
	set functions as they were failing (see changes above)

	* hald/Makefile.am (hald_test_SOURCES): Remove callout.[ch] as they
	are now gone



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/Makefile.am,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- Makefile.am	8 Feb 2005 21:37:47 -0000	1.43
+++ Makefile.am	16 Feb 2005 18:39:56 -0000	1.44
@@ -15,7 +15,6 @@
 
 hald_test_SOURCES =                                                     \
 	hald_marshal.h			hald_marshal.c			\
-	callout.h			callout.c			\
 	device.h			device.c			\
 	device_info.h			device_info.c			\
 	device_store.h			device_store.c			\

Index: hald_dbus.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_dbus.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- hald_dbus.c	14 Feb 2005 18:20:04 -0000	1.22
+++ hald_dbus.c	16 Feb 2005 18:39:56 -0000	1.23
@@ -287,8 +287,6 @@
 	DBusMessageIter iter;
 	DBusMessageIter iter_array;
 
-	HAL_TRACE (("entering"));
-
 	reply = dbus_message_new_method_return (message);
 	if (reply == NULL)
 		DIE (("No memory"));
@@ -810,13 +808,11 @@
 						  DBUS_TYPE_STRING_AS_STRING,
 						  &iter_array);
 
-		for (iter = hal_property_get_strlist (p); 
-				     iter != NULL; 
-				     iter = iter->next) {
+		for (iter = hal_property_get_strlist (p); iter != NULL; iter = iter->next) {
 				     
 			const char *v;
 			v = (const char *) iter->data;
-			
+
 			dbus_message_iter_append_basic (&iter_array, 
 							DBUS_TYPE_STRING,
 							&v);

Index: hald_test_libhal.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald_test_libhal.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- hald_test_libhal.c	14 Feb 2005 18:20:04 -0000	1.3
+++ hald_test_libhal.c	16 Feb 2005 18:39:56 -0000	1.4
@@ -240,11 +240,129 @@
 			goto fail;
 		}
 		printf ("SUCCESS108\n");
+	
+		/* tests for libhal_psi */
+		{
+			int type;
+			char *key;
+			LibHalPropertySet *pset;
+			LibHalPropertySetIterator it;
+			unsigned int psi_num_passed;
+			unsigned int psi_num_elems;
+
+			if ((pset = libhal_device_get_all_properties (ctx, "/org/freedesktop/Hal/devices/testobj1", 
+								      &error)) == NULL)
+				return FALSE;
+			printf ("SUCCESS110\n");
+
+			psi_num_passed = 0;
+			psi_num_elems = libhal_property_set_get_num_elems (pset);
+
+			for (libhal_psi_init (&it, pset); libhal_psi_has_more (&it); libhal_psi_next (&it)) {
+				type = libhal_psi_get_type (&it);
+				key = libhal_psi_get_key (&it);
+
+				switch (type) {
+				case LIBHAL_PROPERTY_TYPE_STRING:
+					if (strcmp (key, "info.udi") == 0) {
+						if (strcmp (libhal_psi_get_string (&it), 
+							    "/org/freedesktop/Hal/devices/testobj1") == 0) {
+							psi_num_passed++;
+						} else {
+							printf ("fail on %s\n", key);
+						}
+					} else if (strcmp (key, "test.string") == 0) {
+						if (strcmp (libhal_psi_get_string (&it), 
+							    "fooooobar22") == 0) {
+							psi_num_passed++;
+						} else {
+							printf ("fail on %s\n", key);
+						}
+					} else if (strcmp (key, "test.string2") == 0) {
+						if (strcmp (libhal_psi_get_string (&it), 
+							    "fooøةמ") == 0) {
+							psi_num_passed++;
+						} else {
+							printf ("fail on %s\n", key);
+						}
+					}
+					break;
+
+				case LIBHAL_PROPERTY_TYPE_INT32:
+					if (strcmp (key, "test.int") == 0) {
+						if (libhal_psi_get_int (&it) == 42)
+							psi_num_passed++;
+						else
+							printf ("fail on %s\n", key);
+					}
+					break;
+
+				case LIBHAL_PROPERTY_TYPE_UINT64:
+					if (strcmp (key, "test.uint64") == 0) {
+						if (libhal_psi_get_uint64 (&it) == ((((dbus_uint64_t)1)<<35) + 5))
+							psi_num_passed++;
+						else
+							printf ("fail on %s\n", key);
+					}
+					break;
+
+				case LIBHAL_PROPERTY_TYPE_BOOLEAN:
+					if (strcmp (key, "test.bool") == 0) {
+						if (libhal_psi_get_bool (&it))
+							psi_num_passed++;
+						else
+							printf ("fail on %s\n", key);
+					}
+					break;
+
+				case LIBHAL_PROPERTY_TYPE_DOUBLE:
+					if (strcmp (key, "test.double") == 0) {
+						double val = 0.53434343;
+						double val2;
+
+						val2 = libhal_psi_get_double (&it);
+						if (memcmp (&val, &val2, sizeof (double)) == 0)
+							psi_num_passed++;
+						else
+							printf ("fail on %s\n", key);
+					}
+					break;
+
+				case LIBHAL_PROPERTY_TYPE_STRLIST:
+					if (strcmp (key, "test.strlist") == 0) {
+						char **val;
+					
+						val = libhal_psi_get_strlist (&it);
+						if (libhal_string_array_length (val) == 2 &&
+						    strcmp (val[0], "foostrlist2") == 0 &&
+						    strcmp (val[1], "foostrlist3") == 0 &&
+						    val[2] == NULL)
+							psi_num_passed++;
+						else
+							printf ("fail on %s\n", key);
+					}
+					break;
+
+				default:
+					printf ("    *** unknown type for key %s\n", key);
+					break;
+				}
+			}
+			libhal_free_property_set (pset);
 
+			if (psi_num_passed != psi_num_elems) {
+				printf ("FAILED111\n");			
+				goto fail;
+			}
+			printf ("SUCCESS111\n");			
+
+
+		} /* end libhal_test_psi */
 
+	
 		printf ("Passed all libhal tests\n");
 		passed = TRUE;
-
+		
 	fail:
 
 		send_tests_done (conn, passed);




More information about the hal-commit mailing list