aboutsummaryrefslogtreecommitdiffstats
path: root/libfsoframework
diff options
context:
space:
mode:
authorMichael 'Mickey' Lauer <mickey@vanille-media.de>2010-01-12 18:40:51 +0100
committerMichael 'Mickey' Lauer <mickey@vanille-media.de>2010-01-12 18:40:51 +0100
commit2d6810ff0c89b5529498d091fbc355692f805e27 (patch)
tree8ab599acb4c5855c9d39980c8ecaecd15f96191c /libfsoframework
parent56a5b9fc52fc658725997f7d1beca8d3e594b165 (diff)
downloadcornucopia-2d6810ff0c89b5529498d091fbc355692f805e27.tar.gz
cornucopia-2d6810ff0c89b5529498d091fbc355692f805e27.tar.bz2
cornucopia-2d6810ff0c89b5529498d091fbc355692f805e27.zip
BIG CHANGE: move generic utility classes that have nothing to do with the framework, subsystems, or plugins into libfsobasics.
Bump versions to reflect actual state and add some more unit tests.
Diffstat (limited to 'libfsoframework')
-rw-r--r--libfsoframework/configure.ac14
-rw-r--r--libfsoframework/fsoframework/Makefile.am14
-rw-r--r--libfsoframework/fsoframework/asyncworker.vala77
-rw-r--r--libfsoframework/fsoframework/inotifier.vala168
-rw-r--r--libfsoframework/fsoframework/kobjectnotifier.vala211
-rw-r--r--libfsoframework/fsoframework/netlinknotifier.vala226
-rw-r--r--libfsoframework/fsoframework/overlay.vala62
-rw-r--r--libfsoframework/fsoframework/process.vala204
-rw-r--r--libfsoframework/fsoframework/syncasync.vala98
-rw-r--r--libfsoframework/tests/Makefile.am76
-rw-r--r--libfsoframework/tests/overlayfile.txt1
-rw-r--r--libfsoframework/tests/testasyncworker.vala58
-rw-r--r--libfsoframework/tests/testinotifier.vala59
-rw-r--r--libfsoframework/tests/testkobjectnotifier.vala46
-rw-r--r--libfsoframework/tests/testnetlinknotifier.vala46
-rw-r--r--libfsoframework/tests/testoverlay.vala51
-rw-r--r--libfsoframework/tests/testprocess.vala73
-rw-r--r--libfsoframework/tests/testsmartkeyfile.ini27
-rw-r--r--libfsoframework/tests/testtransport.vala218
19 files changed, 6 insertions, 1723 deletions
diff --git a/libfsoframework/configure.ac b/libfsoframework/configure.ac
index 84a3f872..7eef3a24 100644
--- a/libfsoframework/configure.ac
+++ b/libfsoframework/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([libfsoframework], [0.2.5], [smartphones-userland@linuxtogo.org], [libfsoframework])
+AC_INIT([libfsoframework], [0.8.0], [smartphones-userland@linuxtogo.org], [libfsoframework])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([dist-bzip2])
@@ -16,14 +16,12 @@ AC_SUBST(LDFLAGS)
# pkg-config requirements
PKG_PROG_PKG_CONFIG
-
-VALA_REQUIRED=0.7.9
+VALA_REQUIRED=0.7.9.7
DBUS_REQUIRED=1.2.1
DBUS_GLIB_REQUIRED=0.76
GLIB_REQUIRED=2.18.0
ALSA_REQUIRED=0.20
-FSOBASICS_REQUIRED=0.9.1
-LIBNL_REQUIRED=2.0
+FSOBASICS_REQUIRED=0.9.9
# vala
AC_PATH_PROG(VALAC, valac, valac)
@@ -58,12 +56,6 @@ PKG_CHECK_MODULES(FSOBASICS,
AC_SUBST(FSOBASICS_CFLAGS)
AC_SUBST(FSOBASICS_LIBS)
-# libnl-2.0
-PKG_CHECK_MODULES(LIBNL,
- libnl-2.0 >= $LIBNL_REQUIRED)
-AC_SUBST(LIBNL_CFLAGS)
-AC_SUBST(LIBNL_LIBS)
-
# gather libdir
if test "x$prefix" != "xNONE"; then
pkglibdir='${prefix}/lib/cornucopia'
diff --git a/libfsoframework/fsoframework/Makefile.am b/libfsoframework/fsoframework/Makefile.am
index 47e15d1d..84036f72 100644
--- a/libfsoframework/fsoframework/Makefile.am
+++ b/libfsoframework/fsoframework/Makefile.am
@@ -2,13 +2,12 @@ include $(top_srcdir)/Makefile.decl
NULL =
-AM_CPPFLAGS = \
+AM_CFLAGS = \
-I$(top_srcdir) \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(ALSA_CFLAGS) \
$(FSOBASICS_CFLAGS) \
- $(LIBNL_CFLAGS) \
$(NULL)
VALAC_ARGS = \
@@ -22,14 +21,13 @@ VALAC_ARGS = \
--pkg dbus-glib-1 \
--pkg alsa \
--pkg fsobasics-2.0 \
- --pkg libnl-2.0 \
--pkg config \
--header fsoframework.h \
--library fsoframework-2.0
if WANT_DEBUG
VALAC_ARGS += -g -D DEBUG
-AM_CFLAGS = -ggdb -O0
+AM_CFLAGS += -ggdb -O0
endif
BUILT_SOURCES = fsoframework.vala.stamp
@@ -40,19 +38,12 @@ lib_LTLIBRARIES = \
libfsoframework_la_VALASOURCES = \
alsa.vala \
- asyncworker.vala \
common.vala \
dbus.vala \
- inotifier.vala \
interfaces.vala \
- kobjectnotifier.vala \
- netlinknotifier.vala \
object.vala \
- overlay.vala \
plugin.vala \
- process.vala \
subsystem.vala \
- syncasync.vala \
$(NULL)
libfsoframework_la_SOURCES = \
@@ -72,7 +63,6 @@ libfsoframework_la_LIBADD = \
$(DBUS_LIBS) \
$(ALSA_LIBS) \
$(FSOBASICS_LIBS) \
- $(LIBNL_LIBS) \
$(NULL)
vapidir = $(datadir)/vala/vapi
diff --git a/libfsoframework/fsoframework/asyncworker.vala b/libfsoframework/fsoframework/asyncworker.vala
deleted file mode 100644
index c8857e32..00000000
--- a/libfsoframework/fsoframework/asyncworker.vala
+++ /dev/null
@@ -1,77 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-/**
- * @class FsoFramework.AbstractWorkerQueue
- **/
-public abstract interface FsoFramework.AbstractWorkerQueue<T> : GLib.Object
-{
- public delegate void WorkerFunc( T element );
-
- public abstract void setDelegate( WorkerFunc worker );
- public abstract void enqueue( T element );
- public abstract void trigger();
-}
-
-/**
- * @class FsoFramework.AsyncWorkerQueue
- **/
-public class FsoFramework.AsyncWorkerQueue<T> : FsoFramework.AbstractWorkerQueue<T>, GLib.Object
-{
- protected GLib.Queue<T> q;
- protected AbstractWorkerQueue.WorkerFunc worker;
- uint watch;
-
- protected bool _onIdle()
- {
- assert( worker != null );
-
- worker( q.pop_tail() );
- watch = 0;
- return false; // don't call again
- }
-
- construct
- {
- q = new GLib.Queue<T>();
- }
-
- public void setDelegate( AbstractWorkerQueue.WorkerFunc worker )
- {
- this.worker = worker;
- trigger();
- }
-
- public void enqueue( T element )
- {
- var retrigger = ( q.length == 0 );
- q.push_head( element );
-
- if ( retrigger && worker != null )
- trigger();
- }
-
- public void trigger()
- {
- assert( q.length > 0 );
- assert( worker != null );
- watch = GLib.Idle.add( _onIdle );
- }
-}
-
diff --git a/libfsoframework/fsoframework/inotifier.vala b/libfsoframework/fsoframework/inotifier.vala
deleted file mode 100644
index 112ad0db..00000000
--- a/libfsoframework/fsoframework/inotifier.vala
+++ /dev/null
@@ -1,168 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-public delegate void FsoFramework.INotifyNotifierFunc( Linux.InotifyMaskFlags flags, uint32 cookie, string? name );
-
-[Compact]
-internal class INotifyDelegateHolder
-{
- public FsoFramework.INotifyNotifierFunc func;
- public INotifyDelegateHolder( FsoFramework.INotifyNotifierFunc func )
- {
- this.func = func;
- }
-}
-
-/**
- * @class FsoFramework.INotifier
- **/
-public class FsoFramework.INotifier : Object
-{
- public static INotifier instance;
-
- private HashTable<int,INotifyDelegateHolder> delegates;
-
- private int fd = -1;
- private uint watch;
- private IOChannel channel;
-
- private char[] buffer;
-
- private const ssize_t BUFFER_LENGTH = 4096;
-
- public INotifier()
- {
- buffer = new char[BUFFER_LENGTH];
- delegates = new HashTable<int,INotifyDelegateHolder>( direct_hash, direct_equal );
-
- fd = Linux.inotify_init();
- if ( fd == -1 )
- {
- error( @"Can not init the inotify subsystem: $(strerror(errno)); some features will not work" );
- return;
- }
- channel = new IOChannel.unix_new( fd );
- watch = channel.add_watch( IOCondition.IN | IOCondition.HUP, onActionFromInotify );
-#if DEBUG
- debug( "inotifier created" );
-#endif
- }
-
- ~INotifier()
- {
- if ( watch != 0 )
- Source.remove( watch );
-
- if ( fd != -1 )
- Posix.close( fd );
- }
-
- protected bool onActionFromInotify( IOChannel source, IOCondition condition )
- {
- if ( ( condition & IOCondition.HUP ) == IOCondition.HUP )
- {
- error( "HUP on inotify, will no longer get any notifications" );
- return false;
- }
-
- if ( ( condition & IOCondition.IN ) == IOCondition.IN )
- {
- assert( fd != -1 );
- assert( buffer != null );
- ssize_t bytesread = Posix.read( fd, buffer, BUFFER_LENGTH );
-
- Linux.InotifyEvent* pevent = (Linux.InotifyEvent*) buffer;
- handleEvent( *pevent );
-
- return true;
- }
-
- critical( "Unsupported IOCondition %u", (int)condition );
- return true;
- }
-
- protected void handleEvent( Linux.InotifyEvent event )
- {
-#if DEBUG
- message( "got inotify event" );
-#endif
- unowned INotifyDelegateHolder holder = delegates.lookup( event.wd );
- assert( holder != null );
-
- holder.func( (Linux.InotifyMaskFlags)event.mask, event.cookie, event.len > 0 ? event.name : null );
- }
-
- protected uint _add( string path, Linux.InotifyMaskFlags mask, INotifyNotifierFunc cb )
- {
- var wd = Linux.inotify_add_watch( fd, path, mask );
-#if DEBUG
- debug( "wd = %d", wd );
-#endif
- if ( wd == -1 )
- {
- error( @"inotify_add_watch: $(strerror(errno))" );
- return 0;
- }
- else
- {
- delegates.insert( wd, new INotifyDelegateHolder( cb ) );
-#if DEBUG
- debug( "inotifier watch added, total %u", delegates.size() );
-#endif
- return wd;
- }
- }
-
- protected void _remove( uint source )
- {
- unowned INotifyDelegateHolder holder = delegates.lookup( (int)source );
- if ( holder != null )
- {
- Linux.inotify_rm_watch( fd, (int)source );
- delegates.remove( (int)source );
-#if DEBUG
- debug( "inotifier watch removed, total %u", delegates.size() );
-#endif
- }
- }
-
- //
- // public API
- //
- public static uint add( string path, Linux.InotifyMaskFlags mask, INotifyNotifierFunc cb )
- {
- if ( INotifier.instance == null )
- {
- INotifier.instance = new INotifier();
- }
- return INotifier.instance._add( path, mask, cb );
- }
-
- public static void remove( uint source )
- {
- if ( INotifier.instance == null )
- {
- INotifier.instance = new INotifier();
- }
- INotifier.instance._remove( source );
- }
-}
-
diff --git a/libfsoframework/fsoframework/kobjectnotifier.vala b/libfsoframework/fsoframework/kobjectnotifier.vala
deleted file mode 100644
index b6a1355e..00000000
--- a/libfsoframework/fsoframework/kobjectnotifier.vala
+++ /dev/null
@@ -1,211 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-public delegate void FsoFramework.KObjectNotifierFunc( HashTable<string, string> properties );
-
-[Compact]
-internal class KObjectDelegateHolder
-{
- public FsoFramework.KObjectNotifierFunc func;
- public KObjectDelegateHolder( FsoFramework.KObjectNotifierFunc func )
- {
- this.func = func;
- }
-}
-
-/**
- * @class FsoFramework.BaseKObjectNotifier
- **/
-public class FsoFramework.BaseKObjectNotifier : Object
-{
- public static BaseKObjectNotifier instance;
-
- private int fd = -1;
- private uint watch;
- private IOChannel channel;
-
- private char[] buffer;
-
- private const ssize_t BUFFER_LENGTH = 4096;
-
- private HashTable<string, List<KObjectDelegateHolder>> add;
- private HashTable<string, List<KObjectDelegateHolder>> change;
- private HashTable<string, List<KObjectDelegateHolder>> remove;
-
- public BaseKObjectNotifier()
- {
- buffer = new char[BUFFER_LENGTH];
-
- add = new HashTable<string, List<KObjectDelegateHolder>>( str_hash, str_equal );
- change = new HashTable<string, List<KObjectDelegateHolder>>( str_hash, str_equal );
- remove = new HashTable<string, List<KObjectDelegateHolder>>( str_hash, str_equal );
-
- fd = Posix.socket( Linux.Socket.AF_NETLINK, Posix.SOCK_DGRAM, Linux.Netlink.NETLINK_KOBJECT_UEVENT );
- assert( fd != -1 );
-
- Linux.Netlink.SockAddrNl addr = { Linux.Socket.AF_NETLINK,
- 0,
- Posix.getpid(),
- 1 };
-
- var res = Posix.bind( fd, &addr, sizeof( Linux.Netlink.SockAddrNl ) );
- assert( res != -1 );
-
- channel = new IOChannel.unix_new( fd );
- watch = channel.add_watch( IOCondition.IN | IOCondition.HUP, onActionFromSocket );
- }
-
- ~BaseKObjectNotifier()
- {
- if ( watch != 0 )
- Source.remove( watch );
-
- if ( fd != -1 )
- Posix.close( fd );
- }
-
- protected bool onActionFromSocket( IOChannel source, IOCondition condition )
- {
- if ( ( condition & IOCondition.HUP ) == IOCondition.HUP )
- {
- error( "HUP on kobject uevent socket, will no longer get any notifications" );
- return false;
- }
-
- if ( ( condition & IOCondition.IN ) == IOCondition.IN )
- {
- assert( fd != -1 );
- assert( buffer != null );
- ssize_t bytesread = Posix.read( fd, buffer, BUFFER_LENGTH );
- for( int i = 0; i < bytesread-1; ++i )
- if ( buffer[i] == 0x00 )
- buffer[i] = 0x09;
-
- var parts = ( (string)buffer ).split( "\t" );
-
- handleMessage( parts );
-
- return true;
- }
-
- critical( "Unsupported IOCondition %u", (int)condition );
- return true;
- }
-
- protected void handleMessage( string[] parts )
- {
- var properties = new HashTable<string, string>( str_hash, str_equal );
- foreach ( var part in parts )
- {
- message( "%s", part );
- var elements = part.split( "=" );
- if ( elements.length == 2 )
- {
- properties.insert( elements[0], elements[1] );
- }
- }
-
- var action = properties.lookup( "ACTION" );
- assert( action != null );
- var subsystem = properties.lookup( "SUBSYSTEM" );
- assert( subsystem != null );
-#if DEBUG
- debug( @"Dealing with action $action for subsystem $subsystem" );
-#endif
-
- HashTable<string, List<KObjectDelegateHolder>> table = null;
-
- switch( action )
- {
- case "add":
- table = add;
- break;
- case "change":
- table = change;
- break;
- case "remove":
- table = remove;
- break;
- default:
- warning( @"Unsupported kobject message action $action, must be one of { add, change, remove }" );
- break;
- }
-
- weak List<weak KObjectDelegateHolder> list = table.lookup( subsystem );
- if ( list == null )
- return;
-
- foreach( var delegateholder in list )
- delegateholder.func( properties );
- }
-
- protected void _addMatch( string action, string subsystem, KObjectNotifierFunc callback )
- {
- HashTable<string, List<KObjectDelegateHolder>> table = null;
-
- switch( action )
- {
- case "add":
- table = add;
- break;
- case "change":
- table = change;
- break;
- case "remove":
- table = remove;
- break;
- default:
- critical( @"Unsupported action $action in _addMatch, must be one of { add, change, remove }" );
- break;
- }
-
- weak List<KObjectDelegateHolder> list = table.lookup( subsystem );
- if ( list == null )
- {
- List<KObjectDelegateHolder> newlist = new List<KObjectDelegateHolder>();
- newlist.append( new KObjectDelegateHolder( callback ) );
-#if DEBUG
- debug( @"# delegates for action $action and subsystem $subsystem now $(newlist.length())" );
-#endif
- table.insert( subsystem, (owned) newlist );
- }
- else
- {
- list.append( new KObjectDelegateHolder( callback ) );
-#if DEBUG
- debug( @"# delegates for action $action and subsystem $subsystem now $(list.length())" );
-#endif
- }
- }
-
- //
- // public API
- //
- public static void addMatch( string action, string path, KObjectNotifierFunc callback )
- {
- if ( BaseKObjectNotifier.instance == null )
- BaseKObjectNotifier.instance = new BaseKObjectNotifier();
-
- BaseKObjectNotifier.instance._addMatch( action, path, callback );
- }
-
-}
-
diff --git a/libfsoframework/fsoframework/netlinknotifier.vala b/libfsoframework/fsoframework/netlinknotifier.vala
deleted file mode 100644
index 6d443803..00000000
--- a/libfsoframework/fsoframework/netlinknotifier.vala
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-
-public delegate void FsoFramework.NetlinkNotifierFunc( HashTable<string, string> properties );
-
-[Compact]
-internal class NetlinkDelegateHolder
-{
- public FsoFramework.NetlinkNotifierFunc func;
- public NetlinkDelegateHolder( FsoFramework.NetlinkNotifierFunc func )
- {
- this.func = func;
- }
-}
-
-/**
- * @class FsoFramework.BaseNetlinkNotifier
- **/
-public class FsoFramework.BaseNetlinkNotifier : Object
-{
- public static BaseNetlinkNotifier instance;
-
- public Netlink.LinkCache cache;
- public Netlink.Socket socket;
-
- private int fd = -1;
- private uint watch;
- private IOChannel channel;
-
- private char[] buffer;
-
- private const ssize_t BUFFER_LENGTH = 4096;
-
- private HashTable<string, List<NetlinkDelegateHolder>> add;
- private HashTable<string, List<NetlinkDelegateHolder>> change;
- private HashTable<string, List<NetlinkDelegateHolder>> remove;
-
- public BaseNetlinkNotifier()
- {
- buffer = new char[BUFFER_LENGTH];
-
- add = new HashTable<string, List<NetlinkDelegateHolder>>( str_hash, str_equal );
- change = new HashTable<string, List<NetlinkDelegateHolder>>( str_hash, str_equal );
- remove = new HashTable<string, List<NetlinkDelegateHolder>>( str_hash, str_equal );
-
- socket = new Netlink.Socket();
- socket.disable_seq_check();
- socket.modify_cb( Netlink.CallbackType.VALID, Netlink.CallbackKind.CUSTOM, handleNetlinkMessage );
-
- socket.connect( Linux.Netlink.NETLINK_ROUTE );
- socket.link_alloc_cache( out cache );
-
- var res = socket.add_memberships( Linux.Netlink.RTNLGRP_LINK, Linux.Netlink.RTNLGRP_IPV4_IFADDR, Linux.Netlink.RTNLGRP_IPV4_ROUTE );
- assert( res != -1 );
-
- fd = socket.get_fd();
- assert( fd != -1 );
- channel = new IOChannel.unix_new( fd );
- watch = channel.add_watch( IOCondition.IN | IOCondition.HUP, onActionFromSocket );
- }
-
- ~BaseNetlinkNotifier()
- {
- if ( watch != 0 )
- Source.remove( watch );
-
- if ( fd != -1 )
- Posix.close( fd );
- }
-
- protected bool onActionFromSocket( IOChannel source, IOCondition condition )
- {
- if ( ( condition & IOCondition.HUP ) == IOCondition.HUP )
- {
- error( "HUP on netlink route socket, will no longer get any notifications" );
- return false;
- }
-
- if ( ( condition & IOCondition.IN ) == IOCondition.IN )
- {
- assert( fd != -1 );
- socket.recvmsgs_default();
- return true;
- }
-
- critical( "Unsupported IOCondition %u", (int)condition );
- return true;
- }
-
- protected void handleMessagePart( Netlink.Object obj )
- {
- debug( "handle message part %p", (void*)obj );
- }
-
- protected int handleNetlinkMessage( Netlink.Message msg )
- {
- Netlink.MessageHeader hdr = msg.header();
- debug( "received netlink message w/ type %d", hdr.nlmsg_type );
-
- var res = msg.parse( handleMessagePart );
- if ( res < 0 )
- {
- debug( Netlink.strerror( res ) );
- }
- return Netlink.CallbackAction.OK;
- }
-
- protected void handleMessage( string[] parts )
- {
- var properties = new HashTable<string, string>( str_hash, str_equal );
- foreach ( var part in parts )
- {
- message( "%s", part );
- var elements = part.split( "=" );
- if ( elements.length == 2 )
- {
- properties.insert( elements[0], elements[1] );
- }
- }
-
- var action = properties.lookup( "ACTION" );
- assert( action != null );
- var subsystem = properties.lookup( "SUBSYSTEM" );
- assert( subsystem != null );
-#if DEBUG
- debug( @"Dealing with action $action for subsystem $subsystem" );
-#endif
-
- HashTable<string, List<NetlinkDelegateHolder>> table = null;
-
- switch( action )
- {
- case "add":
- table = add;
- break;
- case "change":
- table = change;
- break;
- case "remove":
- table = remove;
- break;
- default:
- warning( @"Unsupported Netlink message action $action, must be one of { add, change, remove }" );
- break;
- }
-
- weak List<weak NetlinkDelegateHolder> list = table.lookup( subsystem );
- if ( list == null )
- return;
-
- foreach( var delegateholder in list )
- delegateholder.func( properties );
- }
-
- protected void _addMatch( string action, string subsystem, NetlinkNotifierFunc callback )
- {
- return;
-
- HashTable<string, List<NetlinkDelegateHolder>> table = null;
-
- switch( action )
- {
- case "add":
- table = add;
- break;
- case "change":
- table = change;
- break;
- case "remove":
- table = remove;
- break;
- default:
- critical( @"Unsupported action $action in _addMatch, must be one of { add, change, remove }" );
- break;
- }
-
- weak List<NetlinkDelegateHolder> list = table.lookup( subsystem );
- if ( list == null )
- {
- List<NetlinkDelegateHolder> newlist = new List<NetlinkDelegateHolder>();
- newlist.append( new NetlinkDelegateHolder( callback ) );
-#if DEBUG
- debug( @"# delegates for action $action and subsystem $subsystem now $(newlist.length())" );
-#endif
- table.insert( subsystem, (owned) newlist );
- }
- else
- {
- list.append( new NetlinkDelegateHolder( callback ) );
-#if DEBUG
- debug( @"# delegates for action $action and subsystem $subsystem now $(list.length())" );
-#endif
- }
- }
-
- //
- // public API
- //
- public static void addMatch( string action, string path, NetlinkNotifierFunc callback )
- {
- if ( BaseNetlinkNotifier.instance == null )
- BaseNetlinkNotifier.instance = new BaseNetlinkNotifier();
-
- BaseNetlinkNotifier.instance._addMatch( action, path, callback );
- }
-
-}
-
diff --git a/libfsoframework/fsoframework/overlay.vala b/libfsoframework/fsoframework/overlay.vala
deleted file mode 100644
index 3a2b8677..00000000
--- a/libfsoframework/fsoframework/overlay.vala
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-/**
- * @class FsoFramework.OverlayFile
- **/
-public class FsoFramework.OverlayFile : GLib.Object
-{
- private string filename;
-
- public OverlayFile( string filename, string newcontent )
- {
- try
- {
- string contents;
- size_t length;
- GLib.FileUtils.get_contents( filename, out contents, out length );
- GLib.FileUtils.set_contents( filename + ".saved", contents, (ssize_t)length );
- GLib.FileUtils.set_contents( filename, newcontent, newcontent.length );
- this.filename = filename;
- }
- catch ( FileError e )
- {
- warning( @"Could not save $filename: $(strerror(errno))" );
- }
- }
-
- ~OverlayFile()
- {
- if ( filename != null )
- {
- try
- {
- string contents;
- size_t length;
- GLib.FileUtils.get_contents( filename + ".saved", out contents, out length );
- GLib.FileUtils.set_contents( filename, contents, (ssize_t)length );
- GLib.FileUtils.remove( filename + ".saved" );
- }
- catch ( FileError e )
- {
- warning( @"Could not restore $filename: $(strerror(errno))" );
- }
- }
- }
-}
diff --git a/libfsoframework/fsoframework/process.vala b/libfsoframework/fsoframework/process.vala
deleted file mode 100644
index 1c10d10a..00000000
--- a/libfsoframework/fsoframework/process.vala
+++ /dev/null
@@ -1,204 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-/**
- * @interface FsoFramework.IProcessGuard
- **/
-public interface FsoFramework.IProcessGuard : GLib.Object
-{
- public abstract bool launch( string[] command );
- public abstract void stop( int sig = Posix.SIGTERM );
- public abstract void setAutoRelaunch( bool on );
-
- public abstract bool sendSignal( int sig );
- public abstract bool isRunning();
-
- public signal void running();
- public signal void stopped();
-}
-
-/**
- * @class FsoFramework.GProcessGuard
- **/
-public class FsoFramework.GProcessGuard : FsoFramework.IProcessGuard, GLib.Object
-{
- private Pid pid;
- private uint watch;
- private string[] command;
- private bool relaunch;
-
- ~GProcessGuard()
- {
- if ( pid != (Pid)0 )
- {
-#if DEBUG
- debug( "Implicit kill of pid %d due to guard being freed", (int)pid );
-#endif
- relaunch = false;
- stopSendSignal( false );
- }
- }
-
- public bool launch( string[] command )
- {
- this.command = command; // save for possible relaunching
-
- if ( pid != (Pid)0 )
- {
- warning( @"Can't launch $(command[0]); already running as pid %d".printf( (int)pid ) );
- return false;
- }
-
- var res = 0;
- try
- {
- GLib.Process.spawn_async( GLib.Environment.get_variable( "PWD" ),
- command,
- null,
- GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.SEARCH_PATH,
- null,
- out pid );
- }
- catch ( SpawnError e )
- {
- warning( @"Can't spawn $(command[0]): $(strerror(errno))" );
- return false;
- }
-
- watch = GLib.ChildWatch.add( pid, onChildWatchEvent );
- this.running(); // SIGNAL
- return true;
- }
-
- public bool launchWithPipes( string[] command, out int fdin, out int fdout )
- {
- this.command = command; // save for possible relaunching
-
- if ( pid != (Pid)0 )
- {
- warning( @"Can't launch $(command[0]); already running as pid %d".printf( (int)pid ) );
- return false;
- }
-
- var res = 0;
- try
- {
- GLib.Process.spawn_async_with_pipes(
- GLib.Environment.get_variable( "PWD" ),
- command,
- null,
- GLib.SpawnFlags.DO_NOT_REAP_CHILD | GLib.SpawnFlags.SEARCH_PATH,
- null,
- out pid,
- out fdin,
- out fdout,
- null );
- }
- catch ( SpawnError e )
- {
- warning( @"Can't spawn w/ pipes $(command[0]): $(strerror(errno))" );
- return false;
- }
-
- watch = GLib.ChildWatch.add( pid, onChildWatchEvent );
- this.running(); // SIGNAL
- return true;
- }
-
- public void stop( int sig = Posix.SIGTERM )
- {
- stopSendSignal( true );
- }
-
- public void setAutoRelaunch( bool on )
- {
- relaunch = on;
- }
-
- public bool sendSignal( int sig )
- {
- if ( pid == (Pid)0 )
- {
- return false;
- }
-
- var res = Posix.kill( (Posix.pid_t)pid, sig );
- return res == 0;
- }
-
- public bool isRunning()
- {
- return ( pid != (Pid)0 );
- }
-
- //
- // private API
- //
- private void stopSendSignal( bool send )
- {
- _stop( Posix.SIGKILL );
- if ( send )
- {
- this.stopped();
- }
- }
-
- private void onChildWatchEvent( Pid pid, int status )
- {
- if ( this.pid != pid )
- {
- critical( "D'OH!" );
- return;
- }
-#if DEBUG
- debug( "CHILD WATCH EVENT FOR %d: %d", (int)pid, status );
-#endif
- stopSendSignal( true );
-
- if ( relaunch )
- {
-#if DEBUG
- debug( "Relanching requested..." );
-#endif
- if ( ! launch( command ) )
- {
- warning( @"Could not relaunch $(command[0]); disabling." );
- relaunch = false;
- }
- }
- }
-
- private void _stop( int sig )
- {
-#if DEBUG
- debug( "stopping pid %d", (int)pid );
-#endif
- if ( pid == (Pid)0 )
- {
- return;
- }
- GLib.Process.close_pid( pid );
- Posix.kill( (Posix.pid_t)pid, sig );
- if ( watch > 0 )
- {
- GLib.Source.remove( watch );
- }
- pid = (Pid)0;
- }
-}
diff --git a/libfsoframework/fsoframework/syncasync.vala b/libfsoframework/fsoframework/syncasync.vala
deleted file mode 100644
index 8d35fab3..00000000
--- a/libfsoframework/fsoframework/syncasync.vala
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-namespace FsoFramework
-{
- public async void asyncWaitSeconds( int seconds )
- {
- GLib.Timeout.add_seconds( seconds, asyncWaitSeconds.callback );
- yield;
- }
-} /* namespace */
-
-public class FsoFramework.SyncWrapper : GLib.Object
-{
- protected GLib.VoidFunc func;
- protected GLib.MainLoop loop;
-
- public SyncWrapper( owned GLib.VoidFunc func )
- {
- this.func = func;
- loop = new MainLoop();
- // unfortunately a closure does not work here, ideally we'd just:
- // Idle.add( () => { func(); loop.quit(); return false; } );
- // however vala bails out with some target_func not found then
- Idle.add( onIdle );
- loop.run();
- }
-
- protected virtual bool onIdle()
- {
- func();
- loop.quit();
- return false;
- }
-}
-
-public class FsoFramework.WaitForPredicate : GLib.Object
-{
- private GLib.SourceFunc func;
- private GLib.MainLoop loop;
- private int secs;
- private bool timeout;
-
- public static bool Wait( uint secs, owned GLib.SourceFunc func )
- {
- var w = new WaitForPredicate( secs, func );
-#if DEBUG
- debug( "ended with timeout %d", (int)w.timeout );
-#endif
- return w.timeout;
- }
-
- public WaitForPredicate( uint secs, owned GLib.SourceFunc func )
- {
- this.secs = (int)secs;
- this.func = func;
- loop = new MainLoop();
- Timeout.add_seconds( 1, onTimeout );
- loop.run();
- }
-
- protected bool onTimeout()
- {
-#if DEBUG
- debug( "onTimeout: secs = %d", secs );
-#endif
- if ( secs-- == 0 )
- {
- timeout = true;
- loop.quit();
- return false;
- }
-
- timeout = func();
- if ( !timeout )
- {
- loop.quit();
- return false;
- }
- return true;
- }
-}
diff --git a/libfsoframework/tests/Makefile.am b/libfsoframework/tests/Makefile.am
index 064aa83b..3042d1b7 100644
--- a/libfsoframework/tests/Makefile.am
+++ b/libfsoframework/tests/Makefile.am
@@ -2,14 +2,13 @@ include $(top_srcdir)/Makefile.decl
NULL =
-AM_CPPFLAGS = \
+AM_CFLAGS = \
-I$(top_srcdir) \
-I../fsoframework \
$(GLIB_CFLAGS) \
$(DBUS_CFLAGS) \
$(ALSA_CFLAGS) \
$(FSOBASICS_CFLAGS) \
- $(LIBNL_CFLAGS) \
$(NULL)
INCLUDES = \
@@ -22,7 +21,6 @@ progs_ldadd = \
$(DBUS_LIBS) \
$(ALSA_LIBS) \
$(FSOBASICS_LIBS) \
- $(LIBNL_LIBS) \
../fsoframework/libfsoframework.la
VALAC_ARGS = \
@@ -144,54 +142,6 @@ testobject_LDADD = $(progs_ldadd)
EXTRA_DIST += $(testobject_VALASOURCES)
#
-# asyncworker test
-#
-TEST_PROGS += testasyncworker
-testasyncworker_VALASOURCES = testasyncworker.vala
-testasyncworker_SOURCES = testasyncworker.c
-$(testasyncworker_SOURCES): $(testasyncworker_VALASOURCES)
- $(VALAC) $(VALAC_ARGS) $^
- touch $@
-testasyncworker_LDADD = $(progs_ldadd)
-EXTRA_DIST += $(testasyncworker_VALASOURCES)
-
-#
-# inotifier test
-#
-TEST_PROGS += testinotifier
-testinotifier_VALASOURCES = testinotifier.vala
-testinotifier_SOURCES = testinotifier.c
-$(testinotifier_SOURCES): $(testinotifier_VALASOURCES)
- $(VALAC) $(VALAC_ARGS) $^
- touch $@
-testinotifier_LDADD = $(progs_ldadd)
-EXTRA_DIST += $(testinotifier_VALASOURCES)
-
-#
-# kobjectnotifier test
-#
-TEST_PROGS += testkobjectnotifier
-testkobjectnotifier_VALASOURCES = testkobjectnotifier.vala
-testkobjectnotifier_SOURCES = testkobjectnotifier.c
-$(testkobjectnotifier_SOURCES): $(testkobjectnotifier_VALASOURCES)
- $(VALAC) $(VALAC_ARGS) $^
- touch $@
-testkobjectnotifier_LDADD = $(progs_ldadd)
-EXTRA_DIST += $(testkobjectnotifier_VALASOURCES)
-
-#
-# netlinknotifier test
-#
-TEST_PROGS += testnetlinknotifier
-testnetlinknotifier_VALASOURCES = testnetlinknotifier.vala
-testnetlinknotifier_SOURCES = testnetlinknotifier.c
-$(testnetlinknotifier_SOURCES): $(testnetlinknotifier_VALASOURCES)
- $(VALAC) $(VALAC_ARGS) $^
- touch $@
-testnetlinknotifier_LDADD = $(progs_ldadd)
-EXTRA_DIST += $(testnetlinknotifier_VALASOURCES)
-
-#
# soundsystem test
#
TEST_PROGS += testsoundsystem
@@ -203,30 +153,6 @@ $(testsoundsystem_SOURCES): $(testsoundsystem_VALASOURCES)
testsoundsystem_LDADD = $(progs_ldadd)
EXTRA_DIST += $(testsoundsystem_VALASOURCES)
-#
-# process test
-#
-TEST_PROGS += testprocess
-testprocess_VALASOURCES = testprocess.vala
-testprocess_SOURCES = testprocess.c
-$(testprocess_SOURCES): $(testprocess_VALASOURCES)
- $(VALAC) $(VALAC_ARGS) $^
- touch $@
-testprocess_LDADD = $(progs_ldadd)
-EXTRA_DIST += $(testprocess_VALASOURCES)
-
-#
-# overlay test
-#
-TEST_PROGS += testoverlay
-testoverlay_VALASOURCES = testoverlay.vala
-testoverlay_SOURCES = testoverlay.c
-$(testoverlay_SOURCES): $(testoverlay_VALASOURCES)
- $(VALAC) $(VALAC_ARGS) $^
- touch $@
-testoverlay_LDADD = $(progs_ldadd)
-EXTRA_DIST += $(testoverlay_VALASOURCES)
-
CLEANFILES = \
$(TEST_PROGS) \
*.? \
diff --git a/libfsoframework/tests/overlayfile.txt b/libfsoframework/tests/overlayfile.txt
deleted file mode 100644
index 30f0680f..00000000
--- a/libfsoframework/tests/overlayfile.txt
+++ /dev/null
@@ -1 +0,0 @@
-Dieser Satz kein Verb!
diff --git a/libfsoframework/tests/testasyncworker.vala b/libfsoframework/tests/testasyncworker.vala
deleted file mode 100644
index 21eac6ed..00000000
--- a/libfsoframework/tests/testasyncworker.vala
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-using FsoFramework;
-
-int called;
-
-public void queueHandler( int value )
-{
- message( "queueHandler got '%d'", value );
- called++;
-}
-
-//===========================================================================
-void test_asyncworker_create()
-//===========================================================================
-{
- var q = new AsyncWorkerQueue<int>() as AbstractWorkerQueue;
- assert( q != null );
-}
-
-//===========================================================================
-void test_asyncworker_enqueue()
-//===========================================================================
-{
- var q = new AsyncWorkerQueue<int>() as AbstractWorkerQueue;
- for( int i = 0; i < 100; ++i )
- q.enqueue( i );
-}
-
-//===========================================================================
-void main( string[] args )
-//===========================================================================
-{
- Test.init( ref args );
-
- Test.add_func( "/AsyncWorker/AsyncWorkerQueue/Create", test_asyncworker_create );
- Test.add_func( "/AsyncWorker/AsyncWorkerQueue/Enqueue", test_asyncworker_enqueue );
-
- Test.run();
-}
diff --git a/libfsoframework/tests/testinotifier.vala b/libfsoframework/tests/testinotifier.vala
deleted file mode 100644
index 8ce692ab..00000000
--- a/libfsoframework/tests/testinotifier.vala
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-using FsoFramework;
-
-MainLoop loop;
-
-public void myCallback( Linux.InotifyMaskFlags flags, uint32 cookie, string? name )
-{
- debug( "got callback %d, %d, %s", (int)flags, (int)cookie, name );
- loop.quit();
-}
-
-//===========================================================================
-void test_inotifier_add()
-//===========================================================================
-{
- INotifier.add( "/tmp/foo", Linux.InotifyMaskFlags.MODIFY, myCallback );
- loop = new MainLoop();
- loop.run();
-}
-
-//===========================================================================
-void test_inotifier_remove()
-//===========================================================================
-{
- INotifier.remove( 123456 ); // not existing
- var handle = INotifier.add( "/tmp/foo", Linux.InotifyMaskFlags.CREATE, myCallback );
- INotifier.remove( handle );
-}
-
-//===========================================================================
-void main( string[] args )
-//===========================================================================
-{
- Test.init( ref args );
-
- Test.add_func( "/INotifier/Add", test_inotifier_add );
- Test.add_func( "/INotifier/Remove", test_inotifier_remove );
-
- Test.run();
-}
diff --git a/libfsoframework/tests/testkobjectnotifier.vala b/libfsoframework/tests/testkobjectnotifier.vala
deleted file mode 100644
index aa3f1b83..00000000
--- a/libfsoframework/tests/testkobjectnotifier.vala
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-using FsoFramework;
-
-public void callback( HashTable<string, string> properties )
-{
- debug( "got callback for subsystem '%s' with device path '%s'", properties.lookup( "SUBSYSTEM" ), properties.lookup( "DEVPATH" ) );
-}
-
-//===========================================================================
-void test_kobjectnotifier_add_match()
-//===========================================================================
-{
- BaseKObjectNotifier.addMatch( "remove", "power_supply", callback );
-
- ( new MainLoop( null, false ) ).run();
-}
-
-//===========================================================================
-void main( string[] args )
-//===========================================================================
-{
- Test.init( ref args );
-
- Test.add_func( "/KObjectNotifier/AddMatch", test_kobjectnotifier_add_match );
-
- Test.run();
-}
diff --git a/libfsoframework/tests/testnetlinknotifier.vala b/libfsoframework/tests/testnetlinknotifier.vala
deleted file mode 100644
index f2d9b3b0..00000000
--- a/libfsoframework/tests/testnetlinknotifier.vala
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- **/
-
-using GLib;
-using FsoFramework;
-
-public void callback( HashTable<string, string> properties )
-{
- debug( "got callback" );
-}
-
-//===========================================================================
-void test_netlinknotifier_add_match()
-//===========================================================================
-{
- BaseNetlinkNotifier.addMatch( "addaddr", "foo", callback );
-
- ( new MainLoop() ).run();
-}
-
-//===========================================================================
-void main( string[] args )
-//===========================================================================
-{
- Test.init( ref args );
-
- Test.add_func( "/NetlinkNotifier/AddMatch", test_netlinknotifier_add_match );
-
- Test.run();
-}
diff --git a/libfsoframework/tests/testoverlay.vala b/libfsoframework/tests/testoverlay.vala
deleted file mode 100644
index de3ccdeb..00000000
--- a/libfsoframework/tests/testoverlay.vala
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-using FsoFramework;
-
-const string ORIGINAL_CONTENT = "Dieser Satz kein Verb!";
-const string OVERLAY_CONTENT = "This is the overlay content...";
-
-//===========================================================================
-void test_overlay()
-//===========================================================================
-{
- {
- var overlay = new OverlayFile( "./overlayfile.txt", OVERLAY_CONTENT );
- var original = FileHandling.read( "./overlayfile.txt.saved" );
- assert( original == ORIGINAL_CONTENT );
- var contents = FileHandling.read( "./overlayfile.txt" );
- assert( contents == OVERLAY_CONTENT );
- }
- var contents = FileHandling.read( "./overlayfile.txt" );
- assert( contents == ORIGINAL_CONTENT );
- assert( !FileHandling.isPresent( "./overlayfile.txt.saved" ) );
-}
-
-//===========================================================================
-void main( string[] args )
-//===========================================================================
-{
- Test.init( ref args );
-
- Test.add_func( "/Overlay", test_overlay );
-
- Test.run();
-}
diff --git a/libfsoframework/tests/testprocess.vala b/libfsoframework/tests/testprocess.vala
deleted file mode 100644
index 8d8dc5af..00000000
--- a/libfsoframework/tests/testprocess.vala
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-using FsoFramework;
-
-//===========================================================================
-void test_process_launch()
-//===========================================================================
-{
- var guard = new GProcessGuard();
- var ok = guard.launch( { "/bin/sleep", "5" } );
- assert( ok );
-}
-
-//===========================================================================
-void test_process_signals()
-//===========================================================================
-{
- var guard = new GProcessGuard();
- var ok = guard.launch( { "/bin/sleep", "1" } );
- assert( ok );
- bool signalok = false;
- guard.stopped.connect( ( guard ) => { signalok = true; } );
-
- var timeout = WaitForPredicate.Wait( 5, () => { return !signalok; } );
- assert( !timeout );
-}
-
-//===========================================================================
-void test_process_kill()
-//===========================================================================
-{
- var guard = new GProcessGuard();
- var ok = guard.launch( { "/bin/sleep", "60" } );
- assert( ok );
- bool signalok = false;
- guard.stopped.connect( ( guard ) => { signalok = true; } );
- var timeout = WaitForPredicate.Wait( 5, () => {
- guard.stop();
- return !signalok;
- } );
- assert( !timeout );
-}
-
-//===========================================================================
-void main (string[] args)
-//===========================================================================
-{
- Test.init (ref args);
-
- Test.add_func( "/Process/launch", test_process_launch );
- Test.add_func( "/Process/signals", test_process_signals );
- Test.add_func( "/Process/kill", test_process_kill );
-
- Test.run ();
-}
diff --git a/libfsoframework/tests/testsmartkeyfile.ini b/libfsoframework/tests/testsmartkeyfile.ini
deleted file mode 100644
index 37ae773c..00000000
--- a/libfsoframework/tests/testsmartkeyfile.ini
+++ /dev/null
@@ -1,27 +0,0 @@
-[section0]
-
-[section1]
-keypresent = present
-
-[section2]
-keypresent = 42
-
-[section3]
-keypresent = true
-
-[section4]
-keypresent = foo;bar;yo;kurt
-yo1 = 1
-yo2 = 2
-yo3 = 3
-yo4 = 4
-
-[foo.1]
-
-[foo.2]
-
-[foo.]
-
-[foo.bar]
-
-
diff --git a/libfsoframework/tests/testtransport.vala b/libfsoframework/tests/testtransport.vala
deleted file mode 100644
index 413fb351..00000000
--- a/libfsoframework/tests/testtransport.vala
+++ /dev/null
@@ -1,218 +0,0 @@
-/**
- * Copyright (C) 2009-2010 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
-
- * This library 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
- * Lesser General Public License for more details.
-
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-using GLib;
-using FsoFramework;
-
-const char[] TRANSPORT_TEST_STRING = "\r\n+DATA: FOO\r\n";
-const char[] TRANSPORT_READ_STRING = "\r\n+CMS ERROR: YO KURT\r\n";
-
-char[] buffer;
-string readline;
-bool gotHup;
-bool frozen;
-
-void transport_read_func( Transport transport )
-{
- message( "read delegate called" );
- assert( !frozen );
- buffer = new char[512];
- var bytesread = transport.read( (void*)buffer, 512 );
- buffer[bytesread] = 0;
- readline = (string)buffer;
-}
-
-void transport_hup_func( Transport transport )
-{
- message( "hup delegate called" );
- gotHup = true;
- transport.close();
-}
-
-//===========================================================================
-void test_transport_base()
-//===========================================================================
-{
- var t = new BaseTransport( "testing" );
- TransportHupFunc hupfunc;
- TransportReadFunc readfunc;
-// t.getDelegates( out readfunc, out hupfunc );
-// assert( readfunc == null && hupfunc == null );
-
- t.setDelegates( transport_read_func, transport_hup_func );
-// t.getDelegates( out readfunc, out hupfunc );
-// assert( readfunc == read_func && hupfunc == hup_func );
-}
-
-//===========================================================================
-void test_transport_serial()
-//===========================================================================
-{
- Posix.mkfifo( "./myfifo", Posix.S_IROTH|Posix.S_IWOTH|Posix.S_IXOTH );
- var t = new SerialTransport( "./fifo", 115200 );
- t.open();
- assert( t.getName() == "./fifo" );
- t.close();
- Posix.unlink( "./myfifo" );
-}
-
-//===========================================================================
-void test_transport_pty()
-//===========================================================================
-{
- var t1 = new PtyTransport();
- t1.open();
- var name1 = t1.getName();
- assert( name1.has_prefix( "/dev/pts/" ) );
-
- var t2 = new PtyTransport();
- t2.open();
- var name2 = t2.getName();
- assert( name2.has_prefix( "/dev/pts/" ) );
- assert( name1 != name2 );
-
- t2.close();
- t1.close();
-}
-
-//===========================================================================
-void test_transport_pty_write()
-//===========================================================================
-{
- var t = new PtyTransport();
- t.open();
- t.write( TRANSPORT_TEST_STRING, TRANSPORT_TEST_STRING.length );
-
- // transport writes only from mainloop, so give time to do it
- var loop = new MainLoop( null, false );
- MainContext.default().iteration( false );
-
- var fd = Posix.open( t.getName(), Posix.O_RDONLY );
- assert( fd != -1 );
- var buf = new char[512];
- var length = Posix.read( fd, buf, 512 );
- buf[length] = 0;
-
- assert( length == TRANSPORT_TEST_STRING.length );
- assert( Memory.cmp( TRANSPORT_TEST_STRING, buf, TRANSPORT_TEST_STRING.length ) == 0 );
-
-}
-
-//===========================================================================
-void test_transport_pty_read()
-//===========================================================================
-{
- readline = "";
- var t = new PtyTransport();
- t.setDelegates( transport_read_func, transport_hup_func );
- t.open();
-
- // open pts and write something to it, so the other side can pick it up
- var fd = Posix.open( t.getName(), Posix.O_RDWR );
- assert( fd != -1 );
- var written = Posix.write( fd, TRANSPORT_READ_STRING, TRANSPORT_READ_STRING.length );
-
- // transport reads only from mainloop, so give time to do it
- while ( readline == "" )
- {
- MainContext.default().iteration( false );
- }
-
- for( int i = 0; i < TRANSPORT_READ_STRING.length; ++i )
- {
- assert( readline[i] == TRANSPORT_READ_STRING[i] );
- }
-}
-
-//===========================================================================
-void test_transport_pty_hup()
-//===========================================================================
-{
- gotHup = false;
- var t = new PtyTransport();
- t.setDelegates( transport_read_func, transport_hup_func );
- t.open();
-
- // open pts and close it again
- var fd = Posix.open( t.getName(), Posix.O_RDWR );
- assert( fd != -1 );
- Posix.close( fd );
-
- // transport should pick up a HUP change from within mainloop
- while ( !gotHup )
- {
- MainContext.default().iteration( false );
- }
-
- assert( !t.isOpen() );
-}
-
-//===========================================================================
-void test_transport_pty_freeze_thaw()
-//===========================================================================
-{
- var t = new PtyTransport();
- t.setDelegates( transport_read_func, transport_hup_func );
- t.open();
-
- readline = "";
-
- // freeze transport
- t.freeze();
- frozen = true;
-
- // open pts and write something to it, so the other side can pick it up
- var fd = Posix.open( t.getName(), Posix.O_RDWR );
- assert( fd != -1 );
- var written = Posix.write( fd, "HELLO WORLD", 11 );
-
- // give time to pick up (which would be an error, since we're frozen)
- MainContext.default().iteration( false );
- MainContext.default().iteration( false );
- MainContext.default().iteration( false );
-
- // thaw transport
- frozen = false;
- t.thaw();
-
- // transport reads only from mainloop, so give time to do it
- while ( readline == "" )
- {
- MainContext.default().iteration( false );
- }
-
- assert( readline == "HELLO WORLD" );
-}
-
-//===========================================================================
-void main( string[] args )
-//===========================================================================
-{
- Test.init( ref args );
-
- Test.add_func( "/Transport/Base/Create", test_transport_base );
- Test.add_func( "/Transport/Serial/OpenClose", test_transport_serial );
- Test.add_func( "/Transport/Pty/OpenClose", test_transport_pty );
- Test.add_func( "/Transport/Pty/Write", test_transport_pty_write );
- Test.add_func( "/Transport/Pty/Read", test_transport_pty_read );
- Test.add_func( "/Transport/Pty/Hup", test_transport_pty_hup );
- Test.add_func( "/Transport/Pty/FreezeThaw", test_transport_pty_freeze_thaw );
-
- Test.run();
-}