summaryrefslogtreecommitdiffstats
path: root/tinySAK/test
diff options
context:
space:
mode:
Diffstat (limited to 'tinySAK/test')
-rw-r--r--tinySAK/test/Makefile.am7
-rw-r--r--tinySAK/test/droid-makefile28
-rw-r--r--tinySAK/test/stdafx.c26
-rw-r--r--tinySAK/test/stdafx.h37
-rw-r--r--tinySAK/test/targetver.h18
-rw-r--r--tinySAK/test/test.c278
-rw-r--r--tinySAK/test/test.vcproj450
-rw-r--r--tinySAK/test/test_base64.h113
-rw-r--r--tinySAK/test/test_buffer.h44
-rw-r--r--tinySAK/test/test_condwait.h86
-rw-r--r--tinySAK/test/test_fsm.h310
-rw-r--r--tinySAK/test/test_heap.h77
-rw-r--r--tinySAK/test/test_lists.h258
-rw-r--r--tinySAK/test/test_md5.h100
-rw-r--r--tinySAK/test/test_mutex.h80
-rw-r--r--tinySAK/test/test_object.h111
-rw-r--r--tinySAK/test/test_options.h61
-rw-r--r--tinySAK/test/test_params.h68
-rw-r--r--tinySAK/test/test_runnable.h126
-rw-r--r--tinySAK/test/test_safeobject.h90
-rw-r--r--tinySAK/test/test_semaphore.h73
-rw-r--r--tinySAK/test/test_sha1.h96
-rw-r--r--tinySAK/test/test_strings.h75
-rw-r--r--tinySAK/test/test_threads.h48
-rw-r--r--tinySAK/test/test_timer.h104
-rw-r--r--tinySAK/test/test_url.h43
-rw-r--r--tinySAK/test/test_uuid.h35
27 files changed, 2842 insertions, 0 deletions
diff --git a/tinySAK/test/Makefile.am b/tinySAK/test/Makefile.am
new file mode 100644
index 0000000..0e984d8
--- /dev/null
+++ b/tinySAK/test/Makefile.am
@@ -0,0 +1,7 @@
+INCLUDES = -I../src
+
+bin_PROGRAMS = testSAK
+
+testSAK_SOURCES = test.c
+
+testSAK_LDADD = -ltinySAK \ No newline at end of file
diff --git a/tinySAK/test/droid-makefile b/tinySAK/test/droid-makefile
new file mode 100644
index 0000000..2905a66
--- /dev/null
+++ b/tinySAK/test/droid-makefile
@@ -0,0 +1,28 @@
+APP := test
+
+CFLAGS := $(CFLAGS_COMMON) -I../src
+LDFLAGS := $(LDFLAGS_COMMON) -Wl,-Bsymbolic,--whole-archive -l$(PROJECT) -Wl,--entry=main
+
+all: $(APP)
+
+OBJS += $(APP).o
+
+$(APP): $(OBJS)
+ $(CC) $(LDFLAGS) -o $@ $^
+
+%.o: %.c
+ $(CC) -c $(INCLUDE) $(CFLAGS) $< -o $@
+
+install: $(APP)
+ $(ANDROID_SDK_ROOT)/tools/adb push $(APP) $(EXEC_DIR)/$(APP)
+ $(ANDROID_SDK_ROOT)/tools/adb shell chmod 777 $(EXEC_DIR)/$(APP)
+
+run:
+ $(ANDROID_SDK_ROOT)/tools/adb shell $(EXEC_DIR)/$(APP)
+
+#dbg:
+# $(MAKE) $(MAKEFILE) DEBUG="-g -DDEBUG"
+# $(MAKE) $(MAKEFILE) install
+
+clean:
+ @rm -f $(OBJS) $(APP) \ No newline at end of file
diff --git a/tinySAK/test/stdafx.c b/tinySAK/test/stdafx.c
new file mode 100644
index 0000000..59df1b5
--- /dev/null
+++ b/tinySAK/test/stdafx.c
@@ -0,0 +1,26 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/tinySAK/test/stdafx.h b/tinySAK/test/stdafx.h
new file mode 100644
index 0000000..cb6db1a
--- /dev/null
+++ b/tinySAK/test/stdafx.h
@@ -0,0 +1,37 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+
+#ifndef TEST_TINYSAK_STDAFX_H
+#define TEST_TINYSAK_STDAFX_H
+
+#include "targetver.h"
+
+#include <stdio.h>
+
+#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
+#include <tchar.h>
+#endif
+
+//#define TINYSAK_IMPORTS
+
+// TODO: reference additional headers your program requires here
+#endif /* TEST_TINYSAK_STDAFX_H */
diff --git a/tinySAK/test/targetver.h b/tinySAK/test/targetver.h
new file mode 100644
index 0000000..51d3175
--- /dev/null
+++ b/tinySAK/test/targetver.h
@@ -0,0 +1,18 @@
+#ifndef _TEST_TINYSAK_VER
+#define _TEST_TINYSAK_VER
+
+#if (defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE)) && !defined(__SYMBIAN32__)
+// The following macros define the minimum required platform. The minimum required platform
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
+// including the version specified.
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
+#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#endif
+
+#endif
diff --git a/tinySAK/test/test.c b/tinySAK/test/test.c
new file mode 100644
index 0000000..bb590c9
--- /dev/null
+++ b/tinySAK/test/test.c
@@ -0,0 +1,278 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#include "stdafx.h"
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#include "tsk.h"
+
+#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_WCE)
+# define strdup _strdup
+#endif
+
+
+#define LOOP 1
+
+#define RUN_TEST_ALL 0
+#define RUN_TEST_LISTS 0
+#define RUN_TEST_HEAP 0
+#define RUN_TEST_STRINGS 1
+#define RUN_TEST_URL 0
+#define RUN_TEST_THREADS 0
+#define RUN_TEST_MUTEX 0
+#define RUN_TEST_CONDWAIT 0
+#define RUN_TEST_SEMAPHORE 0
+#define RUN_TEST_SAFEOBJECT 0
+#define RUN_TEST_OBJECT 0
+#define RUN_TEST_PARAMS 0
+#define RUN_TEST_OPTIONS 0
+#define RUN_TEST_TIMER 0
+#define RUN_TEST_RUNNABLE 0
+#define RUN_TEST_BUFFER 0
+#define RUN_TEST_MD5 0
+#define RUN_TEST_SHA1 0
+#define RUN_TEST_BASE64 0
+#define RUN_TEST_UUID 0
+#define RUN_TEST_FSM 0
+
+#if RUN_TEST_LISTS || RUN_TEST_ALL
+#include "test_lists.h"
+#endif
+
+#if RUN_TEST_HEAP || RUN_TEST_ALL
+#include "test_heap.h"
+#endif
+
+#if RUN_TEST_STRINGS || RUN_TEST_ALL
+#include "test_strings.h"
+#endif
+
+#if RUN_TEST_URL || RUN_TEST_ALL
+#include "test_url.h"
+#endif
+
+#if RUN_TEST_THREADS || RUN_TEST_ALL
+#include "test_threads.h"
+#endif
+
+#if RUN_TEST_MUTEX || RUN_TEST_ALL
+#include "test_mutex.h"
+#endif
+
+#if RUN_TEST_CONDWAIT || RUN_TEST_ALL
+#include "test_condwait.h"
+#endif
+
+#if RUN_TEST_SEMAPHORE || RUN_TEST_ALL
+#include "test_semaphore.h"
+#endif
+
+#if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
+//#include "test_safeobject.h"
+#endif
+
+#if RUN_TEST_OBJECT || RUN_TEST_ALL
+#include "test_object.h"
+#endif
+
+#if RUN_TEST_PARAMS || RUN_TEST_ALL
+#include "test_params.h"
+#endif
+
+#if RUN_TEST_OPTIONS || RUN_TEST_ALL
+#include "test_options.h"
+#endif
+
+#if RUN_TEST_TIMER || RUN_TEST_ALL
+#include "test_timer.h"
+#endif
+
+#if RUN_TEST_RUNNABLE || RUN_TEST_ALL
+#include "test_runnable.h"
+#endif
+
+#if RUN_TEST_BUFFER || RUN_TEST_ALL
+#include "test_buffer.h"
+#endif
+
+#if RUN_TEST_MD5 || RUN_TEST_ALL
+#include "test_md5.h"
+#endif
+
+#if RUN_TEST_SHA1 || RUN_TEST_ALL
+#include "test_sha1.h"
+#endif
+
+#if RUN_TEST_BASE64 || RUN_TEST_ALL
+#include "test_base64.h"
+#endif
+
+#if RUN_TEST_UUID || RUN_TEST_ALL
+#include "test_uuid.h"
+#endif
+
+#if RUN_TEST_FSM || RUN_TEST_ALL
+#include "test_fsm.h"
+#endif
+
+
+#ifdef _WIN32_WCE
+int _tmain(int argc, _TCHAR* argv[])
+#else
+int main()
+#endif
+{
+ do
+ {
+ /* Print copyright information */
+ printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n");
+
+#if RUN_TEST_LISTS || RUN_TEST_ALL
+ /* linked lists */
+ test_basic_list();
+ printf("\n\n");
+ test_complex_list();
+ printf("\n\n");
+ test_filtered_list();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_HEAP || RUN_TEST_ALL
+ /* heap */
+ test_heap();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_STRINGS || RUN_TEST_ALL
+ /* strings */
+ test_strings();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_URL || RUN_TEST_ALL
+ /* url */
+ test_url();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_THREADS || RUN_TEST_ALL
+ /* threads */
+ test_threads();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_MUTEX || RUN_TEST_ALL
+ /* mutex */
+ test_mutex();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_CONDWAIT || RUN_TEST_ALL
+ /* condwait */
+ test_condwait();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_SEMAPHORE || RUN_TEST_ALL
+ /* semaphore */
+ test_semaphore();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
+ /* safe object */
+ //test_safeobject();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_OBJECT || RUN_TEST_ALL
+ /* object */
+ //test_object();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_PARAMS || RUN_TEST_ALL
+ /* parameters */
+ test_params();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_OPTIONS || RUN_TEST_ALL
+ /* options */
+ test_options();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_TIMER || RUN_TEST_ALL
+ /* timer */
+ test_timer();
+ printf("\n\n");
+#endif
+
+#if RUN_TEST_RUNNABLE || RUN_TEST_ALL
+ /* test runnable. */
+ test_runnable();
+ printf("\n\n");
+#endif
+
+
+#if RUN_TEST_BUFFER || RUN_TEST_ALL
+ /* test buffer */
+ test_buffer();
+#endif
+
+
+#if RUN_TEST_MD5 || RUN_TEST_ALL
+ /* test md5 and hmac_md5 */
+ test_md5();
+ test_hmac_md5();
+#endif
+
+#if RUN_TEST_SHA1 || RUN_TEST_ALL
+ /* test sha1 and hmac_sha-1 */
+ test_sha1();
+ test_hmac_sha1();
+#endif
+
+#if RUN_TEST_BASE64 || RUN_TEST_ALL
+ /* test base64 encoding/decoding */
+ test_base64();
+#endif
+
+#if RUN_TEST_UUID || RUN_TEST_ALL
+ /* test fake UUID (version5) */
+ test_uuid();
+#endif
+
+#if RUN_TEST_FSM || RUN_TEST_ALL
+ /* test FSM */
+ test_fsm();
+#endif
+
+ }
+ while(LOOP);
+
+ getchar();
+
+ return 0;
+}
diff --git a/tinySAK/test/test.vcproj b/tinySAK/test/test.vcproj
new file mode 100644
index 0000000..f47377a
--- /dev/null
+++ b/tinySAK/test/test.vcproj
@@ -0,0 +1,450 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="test"
+ ProjectGUID="{7A1F8D56-A91F-4658-867F-5E24837071C0}"
+ RootNamespace="test"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\win32\include&quot;;&quot;$(SolutionDir)src&quot;"
+ PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT 0x0501"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(OutDir)\tinySAK.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ OutputDirectory="&quot;$(SolutionDir)$(ConfigurationName)\wce&quot;"
+ IntermediateDirectory="&quot;$(SolutionDir)$(ConfigurationName)&quot;"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ ExecutionBucket="7"
+ Optimization="0"
+ AdditionalIncludeDirectories="&quot;$(DOUBANGO_HOME)\thirdparties\wince\include&quot;;&quot;$(SolutionDir)src&quot;"
+ PreprocessorDefinitions="DEBUG_LEVEL=DEBUG_LEVEL_INFO;_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;$(ARCHFAM);$(_ARCHFAM_);_CONSOLE"
+ MinimalRebuild="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(OutDir)\tinySAK.lib"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="8"
+ EntryPointSymbol="mainWCRTStartup"
+ TargetMachine="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCCodeSignTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
+ OutputDirectory="$(SolutionDir)Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
+ IntermediateDirectory="Windows Mobile 5.0 Pocket PC SDK (ARMV4I)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ ExecutionBucket="7"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ WarnAsError="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCCodeSignTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ <DeploymentTool
+ ForceDirty="-1"
+ RemoteDirectory=""
+ RegisterOutput="0"
+ AdditionalFiles=""
+ />
+ <DebuggerTool
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\stdafx.c"
+ >
+ </File>
+ <File
+ RelativePath=".\test.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\targetver.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="tests"
+ >
+ <File
+ RelativePath=".\test_base64.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_buffer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_condwait.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_fsm.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_heap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_lists.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_md5.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_mutex.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_object.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_params.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_runnable.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_safeobject.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_semaphore.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_sha1.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_strings.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_threads.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_timer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_url.h"
+ >
+ </File>
+ <File
+ RelativePath=".\test_uuid.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/tinySAK/test/test_base64.h b/tinySAK/test/test_base64.h
new file mode 100644
index 0000000..ede1d7e
--- /dev/null
+++ b/tinySAK/test/test_base64.h
@@ -0,0 +1,113 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_BASE64_H_
+#define _TEST_BASE64_H_
+
+struct b64_msg
+{
+ const char* ascii;
+ const char* base64;
+};
+
+struct b64_msg b64_msgs[] =
+{
+ { "", "" },
+ { "f", "Zg==" },
+ { "fo", "Zm8=" },
+ { "foo", "Zm9v" },
+ { "foob", "Zm9vYg==" },
+ { "fooba", "Zm9vYmE=" },
+ { "foobar", "Zm9vYmFy" },
+ { "Aladdin:open sesame", "QWxhZGRpbjpvcGVuIHNlc2FtZQ=="},
+ { "Doubango Project", "RG91YmFuZ28gUHJvamVjdA=="},
+ { "Open Source Doubango Framework", "T3BlbiBTb3VyY2UgRG91YmFuZ28gRnJhbWV3b3Jr"},
+ {
+ "* Copyright (C) 2009 Mamadou Diop."
+ "*"
+ "* Contact: Mamadou Diop <diopmamadou(at)doubango.org>"
+ "*"
+ "* This file is part of Open Source Doubango Framework."
+ "*"
+ "* DOUBANGO 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."
+ "*"
+ "* DOUBANGO 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 DOUBANGO."
+ ,
+ "KiBDb3B5cmlnaHQgKEMpIDIwMDkgTWFtYWRvdSBEaW9wLioqIENvbnRhY3Q6IE1hbW"
+ "Fkb3UgRGlvcCA8ZGlvcG1hbWFkb3UoYXQpZG91YmFuZ28ub3JnPioqIFRoaXMgZmls"
+ "ZSBpcyBwYXJ0IG9mIE9wZW4gU291cmNlIERvdWJhbmdvIEZyYW1ld29yay4qKiBET1"
+ "VCQU5HTyBpcyBmcmVlIHNvZnR3YXJlOiB5b3UgY2FuIHJlZGlzdHJpYnV0ZSBpdCBh"
+ "bmQvb3IgbW9kaWZ5KiBpdCB1bmRlciB0aGUgdGVybXMgb2YgdGhlIEdOVSBHZW5lcm"
+ "FsIFB1YmxpYyBMaWNlbnNlIGFzIHB1Ymxpc2hlZCBieSogdGhlIEZyZWUgU29mdHdh"
+ "cmUgRm91bmRhdGlvbiwgZWl0aGVyIHZlcnNpb24gMyBvZiB0aGUgTGljZW5zZSwgb3"
+ "IqIChhdCB5b3VyIG9wdGlvbikgYW55IGxhdGVyIHZlcnNpb24uKiogRE9VQkFOR08g"
+ "aXMgZGlzdHJpYnV0ZWQgaW4gdGhlIGhvcGUgdGhhdCBpdCB3aWxsIGJlIHVzZWZ1bC"
+ "wqIGJ1dCBXSVRIT1VUIEFOWSBXQVJSQU5UWTsgd2l0aG91dCBldmVuIHRoZSBpbXBs"
+ "aWVkIHdhcnJhbnR5IG9mKiBNRVJDSEFOVEFCSUxJVFkgb3IgRklUTkVTUyBGT1IgQS"
+ "BQQVJUSUNVTEFSIFBVUlBPU0UuICBTZWUgdGhlKiBHTlUgR2VuZXJhbCBQdWJsaWMg"
+ "TGljZW5zZSBmb3IgbW9yZSBkZXRhaWxzLioqIFlvdSBzaG91bGQgaGF2ZSByZWNlaX"
+ "ZlZCBhIGNvcHkgb2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlKiBhbG9u"
+ "ZyB3aXRoIERPVUJBTkdPLg=="
+ }
+};
+
+void test_base64()
+{
+ size_t i, size;
+ char *output_e = 0, *output_d = 0;
+
+ for(i=0; i<sizeof(b64_msgs)/sizeof(struct b64_msg); i++){
+ /*===========
+ * Encoding
+ */
+ size = tsk_base64_encode((const uint8_t*)b64_msgs[i].ascii, strlen(b64_msgs[i].ascii), &output_e);
+ if(tsk_striequals(b64_msgs[i].base64, output_e)){
+ TSK_DEBUG_INFO("[BASE64-%d encoding] ==> OK", i);
+ }
+ else{
+ TSK_DEBUG_INFO("[BASE64-%d encoding] ==> NOK", i);
+ }
+ TSK_FREE(output_e);
+
+ /*===========
+ * Decoding
+ */
+ size = tsk_base64_decode((const uint8_t*)b64_msgs[i].base64, strlen(b64_msgs[i].base64), &output_d);
+ if(tsk_striequals(b64_msgs[i].ascii, output_d)){
+ TSK_DEBUG_INFO("[BASE64-%d decoding] ==> OK", i);
+ }
+ else{
+ TSK_DEBUG_INFO("[BASE64-%d decoding] ==> NOK", i);
+ }
+ TSK_FREE(output_d);
+ }
+}
+
+#endif /* _TEST_BASE64_H_ */
diff --git a/tinySAK/test/test_buffer.h b/tinySAK/test/test_buffer.h
new file mode 100644
index 0000000..8f0810e
--- /dev/null
+++ b/tinySAK/test/test_buffer.h
@@ -0,0 +1,44 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_BUFFER_H_
+#define _TEST_BUFFER_H_
+
+void test_buffer()
+{
+ tsk_buffer_t *buffer = tsk_buffer_create_null();
+
+ tsk_buffer_append(buffer, "Diop", strlen("Diop"));
+ tsk_buffer_append(buffer, " ", strlen(" "));
+ tsk_buffer_append(buffer, "Mamadou", strlen("Mamadou"));
+ tsk_buffer_append(buffer, "\r\n", strlen("\r\n"));
+
+ printf("1. Buffer=%s", TSK_BUFFER_TO_STRING(buffer));
+
+ tsk_buffer_append_2(buffer, "val1=[%s] and val2=[%d]r\n", "value1", 12);
+ tsk_buffer_append_2(buffer, "val3=[%s] and val4=[%s]r\n", "458888554778555LL", "1254852");
+
+ printf("2. Buffer=%s", TSK_BUFFER_TO_STRING(buffer));
+
+ TSK_OBJECT_SAFE_FREE(buffer);
+}
+
+#endif /* _TEST_BUFFER_H_ */
diff --git a/tinySAK/test/test_condwait.h b/tinySAK/test/test_condwait.h
new file mode 100644
index 0000000..8b7dae9
--- /dev/null
+++ b/tinySAK/test/test_condwait.h
@@ -0,0 +1,86 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_CONDWAIT_H_
+#define _TEST_CONDWAIT_H_
+
+void *threadfunc_timed(void *parm)
+{
+ tsk_condwait_handle_t *condwait = (tsk_condwait_handle_t *)parm;
+ int ret = 0;
+
+ ret = tsk_condwait_timedwait(condwait, 10);
+ printf("threadfunc_timed/// %d\n", ret);
+
+ return 0;
+}
+
+void *threadfunc_infinite(void *parm)
+{
+ tsk_condwait_handle_t *condwait = (tsk_condwait_handle_t *)parm;
+ int ret = 0;
+
+ ret = tsk_condwait_wait(condwait);
+ printf("threadfunc_infinite/// %d\n", ret);
+
+ return 0;
+}
+
+void *threadfunc_onemore(void *parm)
+{
+ tsk_condwait_handle_t *condwait = (tsk_condwait_handle_t *)parm;
+ int ret = 0;
+
+ ret = tsk_condwait_wait(condwait);
+ printf("threadfunc_onemore/// %d\n", ret);
+
+ return 0;
+}
+
+
+
+/* Pthread condwait */
+void test_condwait()
+{
+ tsk_condwait_handle_t *condwait = tsk_condwait_create();
+ int ret;
+ void* tid[3] = {0,0,0};
+
+ printf("test_condwait//\n");
+
+ tsk_thread_create(&tid[0], threadfunc_timed, condwait);
+ tsk_thread_create(&tid[1], threadfunc_infinite, condwait);
+ tsk_thread_create(&tid[2], threadfunc_onemore, condwait);
+
+ tsk_condwait_timedwait(condwait, 100); /* give the threads the time to start and 'threadfunc_timed' function to timeout */
+
+ ret = tsk_condwait_signal(condwait); /* Release one */
+ ret = tsk_condwait_broadcast(condwait); /* Release all */
+
+
+ tsk_thread_join(&tid[0]);
+ tsk_thread_join(&tid[1]);
+ tsk_thread_join(&tid[2]);
+
+ tsk_condwait_destroy(&condwait);
+}
+
+#endif /* _TEST_CONDWAIT_H_ */
diff --git a/tinySAK/test/test_fsm.h b/tinySAK/test/test_fsm.h
new file mode 100644
index 0000000..41c17cb
--- /dev/null
+++ b/tinySAK/test/test_fsm.h
@@ -0,0 +1,310 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_FSM_H_
+#define _TEST_FSM_H_
+
+typedef struct test_fsm_ctx_s
+{
+ unsigned unsubscribing:1;
+}
+test_fsm_ctx_t;
+
+/* ======================== actions ======================== */
+typedef enum test_fsm_action_e
+{
+ test_fsm_action_send,
+ test_fsm_action_1xx,
+ test_fsm_action_2xx,
+ test_fsm_action_401_407_421_494,
+ test_fsm_action_423,
+ test_fsm_action_300_to_699,
+ test_fsm_action_cancel,
+ test_fsm_action_notify,
+ test_fsm_action_unsubscribe,
+ test_fsm_action_refresh,
+ test_fsm_action_transporterror,
+ test_fsm_action_error,
+}
+test_fsm_action_t;
+
+/* ======================== execs ======================== */
+int test_fsm_exec_Started_2_Trying_X_send(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Trying_X_1xx(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Terminated_X_2xx(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Connected_X_2xx(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Trying_X_401_407_421_494(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Trying_X_423(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Terminated_X_300_to_699(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Terminated_X_cancel(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Trying_2_Trying_X_NOTIFY(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Connected_2_Trying_X_unsubscribe(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Connected_2_Trying_X_refresh(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Connected_2_Connected_X_NOTIFY(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Connected_2_Terminated_X_NOTIFY(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Any_2_Trying_X_hangup(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Any_2_Terminated_X_transportError(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+int test_fsm_exec_Any_2_Terminated_X_Error(va_list *app)
+{
+ const test_fsm_ctx_t* ctx = va_arg(*app, const test_fsm_ctx_t *);
+ const void* message = va_arg(*app, const void *);
+
+ return 0;
+}
+
+/* ======================== conds ======================== */
+int test_fsm_cond_unsubscribing(test_fsm_ctx_t* ctx, void* data)
+{
+ return ctx->unsubscribing ? 1 : 0;
+}
+int test_fsm_cond_subscribing(test_fsm_ctx_t* ctx, void* data)
+{
+ return !test_fsm_cond_unsubscribing(ctx, data);
+}
+
+int test_fsm_cond_notify_terminated(test_fsm_ctx_t* ctx, void* sipmessage)
+{
+ return 0;
+}
+
+int test_fsm_cond_notify_not_terminated(test_fsm_ctx_t* ctx, void* sipmessage)
+{
+ return !test_fsm_cond_notify_terminated(ctx, sipmessage);
+}
+
+typedef enum test_fsm_state_e
+{
+ __nil = 0,
+ Started,
+ Trying,
+ Connected,
+ Terminated
+}
+test_fsm_state_t;
+
+
+int test_fsm_onterminated(const test_fsm_ctx_t* ctx)
+{
+ TSK_DEBUG_INFO("FSM in terminal state.");
+ return 0;
+}
+
+#define TEST_FSM_ACTIONS_COUNT 5
+test_fsm_action_t test_fsm_tests[TEST_FSM_ACTIONS_COUNT][TEST_FSM_ACTIONS_COUNT] =
+{
+ { test_fsm_action_send, test_fsm_action_300_to_699 },
+ { test_fsm_action_send, test_fsm_action_401_407_421_494, test_fsm_action_2xx, test_fsm_action_refresh, test_fsm_action_300_to_699},
+ { test_fsm_action_send, test_fsm_action_401_407_421_494, test_fsm_action_2xx, test_fsm_action_refresh, test_fsm_action_2xx},
+ { test_fsm_action_send, test_fsm_action_2xx, test_fsm_action_2xx, test_fsm_action_refresh, test_fsm_action_2xx},
+ { test_fsm_action_send, test_fsm_action_423, test_fsm_action_2xx, test_fsm_action_refresh, test_fsm_action_401_407_421_494},
+};
+
+
+void test_fsm()
+{
+ size_t i;
+
+ for(i=0; i<TEST_FSM_ACTIONS_COUNT; i++)
+ {
+ size_t j;
+ tsk_fsm_t* fsm = tsk_fsm_create(Started, Terminated);
+ test_fsm_ctx_t ctx;
+ ctx.unsubscribing = 0;
+
+ tsk_fsm_set_callback_terminated(fsm, test_fsm_onterminated, &ctx);
+
+ tsk_fsm_set(fsm,
+
+ /*=======================
+ * === Any ===
+ */
+ // Any -> (transport error) -> Terminated
+ TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, test_fsm_action_transporterror, Terminated, test_fsm_exec_Any_2_Terminated_X_transportError, "test_fsm_exec_Any_2_Terminated_X_transportError"),
+ // Any -> (transport error) -> Terminated
+ TSK_FSM_ADD_ALWAYS(tsk_fsm_state_any, test_fsm_action_error, Terminated, test_fsm_exec_Any_2_Terminated_X_Error, "test_fsm_exec_Any_2_Terminated_X_Error"),
+ // Any -> (hangup) -> Terminated
+ // Any -> (hangup) -> Trying
+
+ /*=======================
+ * === Started ===
+ */
+ // Started -> (Send) -> Trying
+ TSK_FSM_ADD_ALWAYS(Started, test_fsm_action_send, Trying, test_fsm_exec_Started_2_Trying_X_send, "test_fsm_exec_Started_2_Trying_X_send"),
+ // Started -> (Any) -> Started
+ TSK_FSM_ADD_ALWAYS_NOTHING(Started, "test_fsm_exec_Started_2_Started_X_any"),
+
+
+ /*=======================
+ * === Trying ===
+ */
+ // Trying -> (1xx) -> Trying
+ TSK_FSM_ADD_ALWAYS(Trying, test_fsm_action_1xx, Trying, test_fsm_exec_Trying_2_Trying_X_1xx, "test_fsm_exec_Trying_2_Trying_X_1xx"),
+ // Trying -> (2xx) -> Terminated
+ TSK_FSM_ADD(Trying, test_fsm_action_2xx, test_fsm_cond_unsubscribing, Terminated, test_fsm_exec_Trying_2_Terminated_X_2xx, "test_fsm_exec_Trying_2_Terminated_X_2xx"),
+ // Trying -> (2xx) -> Connected
+ TSK_FSM_ADD(Trying, test_fsm_action_2xx, test_fsm_cond_subscribing, Connected, test_fsm_exec_Trying_2_Connected_X_2xx, "test_fsm_exec_Trying_2_Connected_X_2xx"),
+ // Trying -> (401/407/421/494) -> Trying
+ TSK_FSM_ADD_ALWAYS(Trying, test_fsm_action_401_407_421_494, Trying, test_fsm_exec_Trying_2_Trying_X_401_407_421_494, "test_fsm_exec_Trying_2_Trying_X_401_407_421_494"),
+ // Trying -> (423) -> Trying
+ TSK_FSM_ADD_ALWAYS(Trying, test_fsm_action_423, Trying, test_fsm_exec_Trying_2_Trying_X_423, "test_fsm_exec_Trying_2_Trying_X_423"),
+ // Trying -> (300_to_699) -> Terminated
+ TSK_FSM_ADD_ALWAYS(Trying, test_fsm_action_300_to_699, Terminated, test_fsm_exec_Trying_2_Terminated_X_300_to_699, "test_fsm_exec_Trying_2_Terminated_X_300_to_699"),
+ // Trying -> (cancel) -> Terminated
+ TSK_FSM_ADD_ALWAYS(Trying, test_fsm_action_cancel, Terminated, test_fsm_exec_Trying_2_Terminated_X_cancel, "test_fsm_exec_Trying_2_Terminated_X_cancel"),
+ // Trying -> (Notify) -> Trying
+ TSK_FSM_ADD_ALWAYS(Trying, test_fsm_action_notify, Trying, test_fsm_exec_Trying_2_Trying_X_NOTIFY, "test_fsm_exec_Trying_2_Trying_X_NOTIFY"),
+ // Trying -> (Any) -> Trying
+ TSK_FSM_ADD_ALWAYS_NOTHING(Trying, "test_fsm_exec_Trying_2_Trying_X_any"),
+
+
+ /*=======================
+ * === Connected ===
+ */
+ // Connected -> (unsubscribe) -> Trying
+ TSK_FSM_ADD_ALWAYS(Connected, test_fsm_action_unsubscribe, Trying, test_fsm_exec_Connected_2_Trying_X_unsubscribe, "test_fsm_exec_Connected_2_Trying_X_unsubscribe"),
+ // Connected -> (refresh) -> Trying
+ TSK_FSM_ADD_ALWAYS(Connected, test_fsm_action_refresh, Trying, test_fsm_exec_Connected_2_Trying_X_refresh, "test_fsm_exec_Connected_2_Trying_X_refresh"),
+ // Connected -> (NOTIFY) -> Connected
+ TSK_FSM_ADD(Connected, test_fsm_action_notify, test_fsm_cond_notify_not_terminated, Connected, test_fsm_exec_Connected_2_Connected_X_NOTIFY, "test_fsm_exec_Connected_2_Connected_X_NOTIFY"),
+ // Connected -> (NOTIFY) -> Terminated
+ TSK_FSM_ADD(Connected, test_fsm_action_notify, test_fsm_cond_notify_terminated, Terminated, test_fsm_exec_Connected_2_Terminated_X_NOTIFY, "test_fsm_exec_Connected_2_Terminated_X_NOTIFY"),
+ // Connected -> (Any) -> Connected
+ TSK_FSM_ADD_ALWAYS_NOTHING(Connected, "test_fsm_exec_Connected_2_Connected_X_any"),
+
+ TSK_FSM_ADD_NULL());
+
+
+ for(j=0; j<TEST_FSM_ACTIONS_COUNT; j++){
+ tsk_fsm_act(fsm, test_fsm_tests[i][j], &ctx, tsk_null, &ctx, tsk_null /*message*/);
+ }
+
+ TSK_OBJECT_SAFE_FREE(fsm);
+
+ printf("\n\n");
+ }
+}
+
+#endif /* _TEST_FSM_H_ */
diff --git a/tinySAK/test/test_heap.h b/tinySAK/test/test_heap.h
new file mode 100644
index 0000000..198c2b4
--- /dev/null
+++ b/tinySAK/test/test_heap.h
@@ -0,0 +1,77 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_HEAP_H_
+#define _TEST_HEAP_H_
+
+
+/* test heap*/
+void test_heap()
+{
+ //int i = 0;
+ //tsk_heap_t heap;
+
+ ///* initialize our memory heap */
+ //tsk_heap_init(&heap);
+
+ ///* heap(1): Ten strings are allocated an all freed when we cleanup the heap */
+ //for(i=0; i<10;i++)
+ //{
+ // char* test = tsk_strdup(&heap, "testing the heap (1)");
+ //}
+ //tsk_heap_cleanup(&heap);
+
+ ///* heap(2): pop memory from the heap*/
+ //{
+ // char* test = tsk_strdup(&heap, "testing the heap (2)");
+ // tsk_free(&heap, (void**)&test);
+
+ // test = tsk_calloc(&heap, 10, 1);
+ // tsk_free(&heap, (void**)&test);
+
+ // test = tsk_malloc(&heap, 10);
+ // tsk_free(&heap, (void**)&test);
+
+ // test = tsk_malloc(&heap, 10);
+ // test = tsk_realloc(&heap, test, 100);
+ // tsk_free(&heap, (void**)&test);
+ //}
+ //
+ ///* heap(3): pop a NULL pointer */
+ //{
+ // tsk_free(&heap, 0);
+ //}
+
+ ///* heap(4): allocate and pop from NULL heap */
+ //{
+ // char* test = tsk_calloc(0, 10, 1);
+ // tsk_free(0, (void**)&test);
+
+ // test = tsk_malloc(0, 10);
+ // tsk_free(0, (void**)&test);
+
+ // test = tsk_malloc(0, 10);
+ // test = tsk_realloc(0, test, 100);
+ // tsk_free(0, (void**)&test);
+ //}
+}
+
+#endif /* _TEST_HEAP_H_ */
diff --git a/tinySAK/test/test_lists.h b/tinySAK/test/test_lists.h
new file mode 100644
index 0000000..2f98793
--- /dev/null
+++ b/tinySAK/test/test_lists.h
@@ -0,0 +1,258 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_LISTS_H_
+#define _TEST_LISTS_H_
+
+//========================================================
+// Person object definition
+//
+typedef struct student_s
+{
+ TSK_DECLARE_OBJECT;
+
+ char *id;
+ char *name;
+}
+student_t;
+
+static void* student_ctor(void * self, va_list * app)
+{
+ student_t* student = self;
+ student->id = tsk_strdup(va_arg(*app, const char *));
+ student->name = tsk_strdup(va_arg(*app, const char *));
+ return self;
+}
+
+static void* student_dtor(void *self)
+{
+ student_t* student = self;
+ tsk_free((void**)&(student->id));
+ tsk_free((void**)&(student->name));
+ return self;
+}
+
+static int student_icmp(const void *self, const void *object)
+{
+ const student_t* student1 = self;
+ const student_t* student2 = object;
+
+ if(!student1 || !student2){
+ return 0;
+ }
+
+ return tsk_stricmp(student1->id, student2->id);
+}
+
+static const tsk_object_def_t student_def_s =
+{
+ sizeof(student_t),
+ student_ctor,
+ student_dtor,
+ student_icmp
+};
+const void *student_def_t = &student_def_s;
+#define STUDENT_CREATE(id, name) tsk_object_new(student_def_t, id, name)
+#define STUDENT_SAFE_FREE(self) tsk_object_unref(self)
+
+static int pred_find_student_by_name(const tsk_list_item_t *item, const void *name)
+{
+ if(item && item->data){
+ student_t *student = item->data;
+ return tsk_striequals(student->name, name);
+ }
+ return -1;
+}
+
+/* testing basic linked list */
+void test_basic_list()
+{
+ tsk_list_t *list = tsk_list_create();
+ tsk_list_item_t *item = tsk_list_item_create();
+
+ /* add items to the list */
+ item->data = tsk_string_create("First item");
+ tsk_list_push_front_item(list, &item);
+
+ item = tsk_list_item_create();
+ item->data = tsk_string_create("Second item");
+ tsk_list_push_back_item(list, &item);
+
+ item = tsk_list_item_create();
+ item->data = tsk_string_create("Third item");
+ tsk_list_push_front_item(list, &item);
+
+ item = tsk_list_item_create();
+ item->data = tsk_string_create("Fourth item");
+ tsk_list_push_back_item(list, &item);
+
+ /* dump all items */
+ tsk_list_foreach(item, list){
+ tsk_string_t* item_data = ((tsk_string_t*)item->data);
+ printf("test_basic_list/// --> [%s]\n", item_data->value);
+ }
+
+ tsk_list_remove_item(list, list->tail);
+ tsk_list_remove_item(list, list->tail);
+ tsk_list_remove_item(list, list->tail);
+ tsk_list_remove_item(list, list->tail);
+
+ /* delete all items in the list */
+ TSK_OBJECT_SAFE_FREE(list);
+}
+
+void test_filtered_list()
+{
+#define PUSH_FILTERED(list, data) tsk_list_push_ascending_data(list, data);
+
+ tsk_list_t *list = tsk_list_create();
+ tsk_list_item_t *item = 0;
+
+ /* add items to the list */
+ {
+ student_t *student2 = STUDENT_CREATE("2", "student2");
+ PUSH_FILTERED(list, ((void**) &student2));
+ }
+ {
+ student_t *student6 = STUDENT_CREATE("6", "student6");
+ PUSH_FILTERED(list, ((void**) &student6));
+ }
+ {
+ student_t *student1 = STUDENT_CREATE("1", "student1");
+ PUSH_FILTERED(list, ((void**) &student1));
+ }
+ {
+ student_t *student6 = STUDENT_CREATE("6", "student6");
+ PUSH_FILTERED(list, ((void**) &student6));
+ }
+ {
+ student_t *student6 = STUDENT_CREATE("6", "student6");
+ PUSH_FILTERED(list, ((void**) &student6));
+ }
+ {
+ student_t *student2 = STUDENT_CREATE("2", "student2");
+ PUSH_FILTERED(list, ((void**) &student2));
+ }
+ {
+ student_t *student2 = STUDENT_CREATE("2", "student2");
+ PUSH_FILTERED(list, ((void**) &student2));
+ }
+ {
+ student_t *student5 = STUDENT_CREATE("5", "student5");
+ PUSH_FILTERED(list, ((void**) &student5));
+ }
+ {
+ student_t *student4 = STUDENT_CREATE("4", "student4");
+ PUSH_FILTERED(list, ((void**) &student4));
+ }
+ {
+ student_t *student1 = STUDENT_CREATE("1", "student1");
+ PUSH_FILTERED(list, ((void**) &student1));
+ }
+ {
+ student_t *student1 = STUDENT_CREATE("1", "student1");
+ PUSH_FILTERED(list, ((void**) &student1));
+ }
+ {
+ student_t *student3 = STUDENT_CREATE("3", "student3");
+ PUSH_FILTERED(list, ((void**) &student3));
+ }
+ {
+ student_t *student6 = STUDENT_CREATE("6", "student6");
+ PUSH_FILTERED(list, ((void**) &student6));
+ }
+ {
+ student_t *student1 = STUDENT_CREATE("1", "student1");
+ PUSH_FILTERED(list, ((void**) &student1));
+ }
+ {
+ student_t *student3 = STUDENT_CREATE("3", "student3");
+ PUSH_FILTERED(list, ((void**) &student3));
+ }
+ {
+ student_t *student6 = STUDENT_CREATE("6", "student6");
+ PUSH_FILTERED(list, ((void**) &student6));
+ }
+
+ /* dump all items */
+ tsk_list_foreach(item, list)
+ {
+ student_t* item_data = item->data;
+ printf("test_filtered_list/// --> [id=%s and name=%s]\n", item_data->id, item_data->name);
+ }
+
+ /* delete all items in the list */
+ TSK_OBJECT_SAFE_FREE(list);
+
+#undef PUSH_FILTERED
+}
+
+void test_complex_list()
+{
+ tsk_list_t *list = tsk_list_create();
+ tsk_list_item_t *item = 0;
+
+ /* add items to the list */
+ {
+ student_t *student1 = STUDENT_CREATE("1", "student1");
+ tsk_list_push_back_data(list, ((void**) &student1));
+ }
+ {
+ student_t *student2 = STUDENT_CREATE("2", "student2");
+ tsk_list_push_front_data(list, ((void**) &student2));
+ }
+ {
+ student_t *student3 = STUDENT_CREATE("3", "student3");
+ tsk_list_push_front_data(list, ((void**) &student3));
+ }
+
+ /* dump all items */
+ tsk_list_foreach(item, list)
+ {
+ student_t* item_data = item->data;
+ printf("test_complex_list/// --> [id=%s and name=%s]\n", item_data->id, item_data->name);
+ }
+
+ /* Find student using tsk_object* */
+ {
+ student_t *student_to_find = STUDENT_CREATE("1", "student1");
+ const tsk_list_item_t *item_const = tsk_list_find_item_by_data(list, student_to_find);
+ {
+ const student_t* item_data_const = item_const->data;
+ printf("test_complex_list/// using tsk_object --> student with name==\"student1\" and id=\"%s\"", item_data_const->id);
+ }
+ STUDENT_SAFE_FREE(student_to_find);
+ }
+
+ /* Find student named "student2" using predicate */
+ {
+ const tsk_list_item_t *item_const = tsk_list_find_item_by_pred(list, pred_find_student_by_name, "student2");
+ {
+ const student_t* item_data_const = item_const->data;
+ printf("test_complex_list/// using predicate --> student with name==\"student2\" and id=\"%s\"", item_data_const->id);
+ }
+ }
+
+ /* delete all items in the list */
+ TSK_OBJECT_SAFE_FREE(list);
+}
+
+#endif /* _TEST_LISTS_H_ */
diff --git a/tinySAK/test/test_md5.h b/tinySAK/test/test_md5.h
new file mode 100644
index 0000000..439826c
--- /dev/null
+++ b/tinySAK/test/test_md5.h
@@ -0,0 +1,100 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_MD5_H_
+#define _TEST_MD5_H_
+
+struct md5_result
+{
+ const char* msg;
+ const char* xres;
+};
+
+struct md5_result msgs_md5[] =
+{
+ { "", "d41d8cd98f00b204e9800998ecf8427e" },
+ { "a", "0cc175b9c0f1b6a831c399e269772661" },
+ { "abc", "900150983cd24fb0d6963f7d28e17f72" },
+ { "message digest", "f96b697d7cb7938d525a2f31aaf161d0" },
+ { "abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b" },
+ { "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f" },
+ { "12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a" },
+ { "The quick brown fox jumps over the lazy dog", "9e107d9d372bb6826bd81d3542a419d6" },
+ { "The quick brown fox jumps over the lazy dog.", "e4d909c290d0fb1ca068ffaddf22cbd0" }
+};
+
+void test_md5()
+{
+ size_t i;
+ tsk_md5string_t md5result;
+
+ for(i=0; i< sizeof(msgs_md5)/sizeof(struct md5_result); i++)
+ {
+ tsk_md5compute(msgs_md5[i].msg, strlen(msgs_md5[i].msg), &md5result);
+ if(tsk_striequals(msgs_md5[i].xres, md5result))
+ {
+ TSK_DEBUG_INFO("[MD5-%d] ==> OK", i);
+ }
+ else
+ {
+ TSK_DEBUG_INFO("[MD5-%d] ==> NOK", i);
+ }
+ }
+}
+
+struct hmac_md5_result
+{
+ const char* msg;
+ const char* key;
+ const char* xres;
+};
+struct hmac_md5_result msgs_hmac_md5[] =
+{
+ { "Hi There", "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", "9294727a3638bb1c13f48ef8158bfc9d" },
+ { "what do ya want for nothing?", "Jefe", "750c783e6ab0b503eaa86e310a5db738" },
+ { "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "56be34521d144c88dbb8c733f0e8b3f6" },
+ { "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd", "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "697eaf0aca3a3aea3a75164746ffaa79" },
+ { "Test With Truncation", "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", "56461ef2342edc00f9bab995690efd4c" },
+ { "Test Using Larger Than Block-Size Key - Hash Key First", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd" },
+ { "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "6f630fad67cda0ee1fb1f562db3aa53e" },
+};
+
+void test_hmac_md5()
+{
+ size_t i;
+ tsk_md5string_t md5result;
+
+ for(i=0; i< sizeof(msgs_hmac_md5)/sizeof(struct hmac_md5_result); i++)
+ {
+ hmac_md5_compute((const uint8_t*)msgs_hmac_md5[i].msg, strlen(msgs_hmac_md5[i].msg), msgs_hmac_md5[i].key, strlen(msgs_hmac_md5[i].key), &md5result);
+ if(tsk_striequals(msgs_hmac_md5[i].xres, md5result))
+ {
+ TSK_DEBUG_INFO("[HMAC-MD5-%d] ==> OK", i);
+ }
+ else
+ {
+ TSK_DEBUG_INFO("[HMAC-MD5-%d] ==> NOK", i);
+ }
+ }
+}
+
+
+#endif /* _TEST_MD5_H_ */
diff --git a/tinySAK/test/test_mutex.h b/tinySAK/test/test_mutex.h
new file mode 100644
index 0000000..c81899f
--- /dev/null
+++ b/tinySAK/test/test_mutex.h
@@ -0,0 +1,80 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+
+
+#ifndef _TEST_MUTEX_H_
+#define _TEST_MUTEX_H_
+
+int mutex_thread_started = 0;
+
+int safe_func(tsk_mutex_handle_t *mutex, const char* caller)
+{
+ int ret = 0;
+
+ ret = tsk_mutex_lock(mutex);
+ TSK_DEBUG_INFO("threadfunc_mutex/// Start doing job [%s]... %d\n", caller, ret);
+ tsk_thread_sleep(5000);
+ TSK_DEBUG_INFO("threadfunc_mutex/// Stop doing job [%s]... %d\n", caller, ret);
+ ret = tsk_mutex_unlock(mutex);
+
+ return ret;
+}
+
+void *threadfunc_mutex(void *parm)
+{
+ tsk_mutex_handle_t *mutex = (tsk_mutex_handle_t *)parm;
+ safe_func(mutex, "caller1");
+
+ return 0;
+}
+
+
+/* Pthread mutex */
+void test_mutex()
+{
+ tsk_mutex_handle_t *mutex = tsk_mutex_create();
+ void* tid[1] = {0};
+
+ TSK_DEBUG_INFO("test_mutex//\n");
+
+ //tsk_mutex_lock(mutex);
+
+ tsk_thread_create(&tid[0], threadfunc_mutex, mutex);
+ tsk_thread_sleep(1000);
+
+ safe_func(mutex, "caller0");
+
+ /*while(!mutex_thread_started) tsk_thread_sleep(1000);
+
+ printf("test_mutex// threadfunc_mutex is locked for 1 second\n");
+ tsk_thread_sleep(1000);
+
+ printf("test_mutex// Now unlock threadfunc_mutex\n");
+ tsk_mutex_unlock(mutex);*/
+
+
+ tsk_thread_join(&(tid[0]));
+
+ tsk_mutex_destroy(&mutex);
+}
+
+#endif /* _TEST_MUTEX_H_ */
diff --git a/tinySAK/test/test_object.h b/tinySAK/test/test_object.h
new file mode 100644
index 0000000..ca8e8d5
--- /dev/null
+++ b/tinySAK/test/test_object.h
@@ -0,0 +1,111 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#if !defined(_TEST_OBJECT_H_) && 0
+#define _TEST_OBJECT_H_
+
+typedef struct person_s
+{
+ TSK_DECLARE_OBJECT; // Mandatory
+
+ char* name;
+ struct person_s* girlfriend;
+}
+person_t;
+
+// (a student is a person)
+typedef struct student_s
+{
+ struct person_s* person; // Must be the first element
+ char* school;
+}
+student_t;
+
+//// (as a student is a person you can do)
+//student_t* s;
+//((person_t*)s)->name = tsk_strdup("bob");
+
+
+// constructor
+static tsk_object_t* person_create(tsk_object_t * self, va_list * app)
+{
+ person_t *person = self;
+ if(person){
+ person->name = tsk_strdup(va_arg(*app, const char *));
+ }
+ return self;
+ }
+
+ // destructor
+ static tsk_object_t* person_destroy(tsk_object_t * self)
+ {
+ person_t *person = self;
+ if(person){
+ TSK_FREE(person->name);
+ tsk_object_unref(person->girlfriend);
+ }
+ return self; // return
+ }
+
+ // comparator
+ static int person_cmp(const tsk_object_t *_p1, const tsk_object_t *_p2)
+ {
+ const person_t *p1 = _p1;
+ const person_t *p1 = _p2;
+ int ret;
+
+ // do they have the same name?
+ if((ret = tsk_stricmp(p1->name, p2->name))){
+ return ret;
+ }
+ // do they have the same girlfriend?
+ if((ret = tsk_object_cmp(p1->girlfriend, p2->girlfriend))){
+ return ret;
+ }
+
+ // they are the same
+ return 0;
+ }
+
+ //(Object defnition)
+ static const tsk_object_def_t person_def_t =
+ {
+ sizeof(person_t),
+ person_create,
+ person_destroy,
+ person_cmp
+ };
+
+ // create a person
+#define PERSON_CREATE(name) tsk_object_new(&person_def_t, (const char*)name)
+
+/* test object */
+void test_object()
+{
+ // creates a person: will call the constructor
+ person_t* bob = PERSON_CREATE("bob");
+ // creates bob's girlfriend
+ bob->girlfriend = PERSON_CREATE("alice");
+ // deletes bob: will delete both bob and bob's girlfriend field by calling their destructors
+ TSK_OBJECT_SAFE_FREE(bob);
+}
+
+#endif /* _TEST_OBJECT_H_ */
diff --git a/tinySAK/test/test_options.h b/tinySAK/test/test_options.h
new file mode 100644
index 0000000..f298f8b
--- /dev/null
+++ b/tinySAK/test/test_options.h
@@ -0,0 +1,61 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_OPTIONS_H_
+#define _TEST_OPTIONS_H_
+
+typedef enum options_e
+{
+ o_project,
+ o_license,
+ o_contact,
+ o_version,
+ o_date
+}
+options_t;
+
+void test_options()
+{
+ tsk_options_L_t *options = tsk_list_create();
+ tsk_bool_t b;
+ int i;
+ const char* string;
+ const tsk_option_t* o;
+
+ tsk_options_add_option(&options, o_project, "doubango");
+ tsk_options_add_option(&options, o_project, "doubangooo");
+ tsk_options_add_option(&options, o_license, "GPLv3");
+ tsk_options_add_option(&options, o_contact, "Mamadou Diop <diopmamadou(at)doubango.org>");
+ tsk_options_add_option(&options, o_version, "10");
+
+ b = tsk_options_have_option(options, o_project);
+ b = tsk_options_have_option(options, o_date);
+ tsk_options_remove_option(options, o_project);
+ b = tsk_options_have_option(options, o_project);
+ i = tsk_options_get_option_value_as_int(options, o_version);
+ string = tsk_options_get_option_value(options, o_version);
+ o = tsk_options_get_option_by_id(options, o_contact);
+
+ TSK_OBJECT_SAFE_FREE(options);
+}
+
+
+#endif /*_TEST_OPTIONS_H_ */
diff --git a/tinySAK/test/test_params.h b/tinySAK/test/test_params.h
new file mode 100644
index 0000000..b7706a5
--- /dev/null
+++ b/tinySAK/test/test_params.h
@@ -0,0 +1,68 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_PARAMS_H_
+#define _TEST_PARAMS_H_
+
+
+void test_params()
+{
+ tsk_buffer_t *buffer = tsk_buffer_create_null();
+ tsk_params_L_t *params = tsk_list_create();
+
+ //
+ //
+ //
+ tsk_param_t *param1 = tsk_params_parse_param("mamadou=diop", strlen("mamadou=diop"));
+ tsk_param_t *param2 = tsk_params_parse_param("project=doubango", strlen("project=doubango"));
+ tsk_param_t *param3 = tsk_params_parse_param("license=gpl", strlen("license=gpl"));
+
+ tsk_list_push_back_data(params, (void**)&param1);
+ tsk_list_push_back_data(params, (void**)&param2);
+ tsk_list_push_back_data(params, (void**)&param3);
+
+ tsk_params_tostring(params, ',', buffer);
+ TSK_DEBUG_INFO("Buffer=[%s]", TSK_BUFFER_TO_STRING(buffer));
+
+ tsk_buffer_cleanup(buffer);
+ TSK_OBJECT_SAFE_FREE(params);
+
+
+ //
+ //
+ //
+ params = tsk_params_fromstring("octet-align=1; mode-set=0,1,2,3,4,5,6,7; mode-change-period=1; mode-change-capability=2; mode-change-neighbor=0", ';', tsk_true);
+ tsk_params_tostring(params, ';', buffer);
+ TSK_DEBUG_INFO("Buffer=[%s]", TSK_BUFFER_TO_STRING(buffer));
+ tsk_buffer_cleanup(buffer);
+ TSK_OBJECT_SAFE_FREE(params);
+
+ params = tsk_params_fromstring("QCIF=1;CIF=2;MaxBR=4200", ';', tsk_true);
+ tsk_params_tostring(params, ';', buffer);
+ TSK_DEBUG_INFO("Buffer=[%s]", TSK_BUFFER_TO_STRING(buffer));
+ tsk_buffer_cleanup(buffer);
+ TSK_OBJECT_SAFE_FREE(params);
+
+ TSK_OBJECT_SAFE_FREE(buffer);
+}
+
+
+#endif /*_TEST_PARAMS_H_ */
diff --git a/tinySAK/test/test_runnable.h b/tinySAK/test/test_runnable.h
new file mode 100644
index 0000000..f55635a
--- /dev/null
+++ b/tinySAK/test/test_runnable.h
@@ -0,0 +1,126 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_RUNNABLE_H_
+#define _TEST_RUNNABLE_H_
+
+typedef struct test_runnable_timer_s
+{
+ tsk_timer_id_t id;
+ uint64_t timeout;
+ const char *arg;
+}
+test_runnable_timer_t;
+
+test_runnable_timer_t runnable_timers[] =
+{
+ {0, 2000, "3"},
+ {1, 2500, "4"},
+ {2, 500, "1"},
+ {3, 1000, "2"},
+ {4, 1000, "2"},
+ {5, 0, "0"},
+ {6, 10000, "6"},
+ {7, 3000, "5"},
+ {8, 2500, "4"},
+};
+
+typedef struct tsk_obj_s
+{
+ TSK_DECLARE_OBJECT;
+
+ tsk_timer_id_t timer_id;
+}
+tsk_obj_t;
+
+static void* tsk_obj_ctor(void * self, va_list * app){
+ tsk_obj_t *obj = self;
+ if(obj){
+ obj->timer_id = va_arg(*app, tsk_timer_id_t);
+ }
+ return self;
+}
+static void* tsk_obj_dtor(void * self) {
+ return self;
+}
+static int tsk_obj_cmp(const void *obj1, const void *obj2){
+ return 0;
+}
+static const tsk_object_def_t tsk_obj_def_s =
+{
+ sizeof(tsk_obj_t),
+ tsk_obj_ctor,
+ tsk_obj_dtor,
+ tsk_obj_cmp,
+};
+const tsk_object_def_t *tsk_obj_def_t = &tsk_obj_def_s;
+
+void *run(void* self)
+{
+ int i = 0;
+ tsk_list_item_t *curr;
+
+ TSK_RUNNABLE_RUN_BEGIN(self);
+
+ if(curr = TSK_RUNNABLE_POP_FIRST(self)){
+ const tsk_obj_t *obj = (const tsk_obj_t*)curr->data;
+ printf("\n\nRunnable event-id===>[%llu]\n\n", obj->timer_id);
+ tsk_object_unref(curr);
+ }
+
+ TSK_RUNNABLE_RUN_END(self);
+
+ return 0;
+}
+
+static int test_runnable_timer_callback(const void* arg, tsk_timer_id_t timer_id)
+{
+ const tsk_runnable_t* runnable = arg;
+ if(runnable){
+ TSK_RUNNABLE_ENQUEUE(runnable, timer_id);
+ return 0;
+ }
+ return -1;
+}
+
+void test_runnable()
+{
+ size_t i;
+ tsk_timer_manager_handle_t *timer_mgr = tsk_timer_manager_create();
+ tsk_runnable_t* runnable = tsk_runnable_create();
+ runnable->run = run;
+ printf("test_runnable//\n");
+
+ tsk_timer_manager_start(timer_mgr);
+ tsk_runnable_start(runnable, tsk_obj_def_t);
+
+ for(i=0; i<sizeof(runnable_timers)/sizeof(test_runnable_timer_t); ++i){
+ runnable_timers[i].id = tsk_timer_manager_schedule(timer_mgr, runnable_timers[i].timeout, test_runnable_timer_callback, runnable);
+ }
+
+ tsk_thread_sleep(4000);
+
+ /* Stops and frees both timer manager and runnable object */
+ TSK_OBJECT_SAFE_FREE(runnable);
+ TSK_OBJECT_SAFE_FREE(timer_mgr);
+}
+
+#endif /* _TEST_RUNNABLE_H_ */
diff --git a/tinySAK/test/test_safeobject.h b/tinySAK/test/test_safeobject.h
new file mode 100644
index 0000000..0220b30
--- /dev/null
+++ b/tinySAK/test/test_safeobject.h
@@ -0,0 +1,90 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_SAFEOBJ_H_
+#define _TEST_SAFEOBJ_H_
+
+int so_mutex_count = 0;
+
+typedef struct mysafeobj_s
+{
+ TSK_DECLARE_SAFEOBJ;
+
+ int test1;
+ int test2;
+}
+mysafeobj_t;
+
+void *threadfunc_safeobj1(void *parm)
+{
+ mysafeobj_t *safeobj = (mysafeobj_t *)parm;
+ int ret = 0;
+
+ so_mutex_count++;
+ ret = tsk_safeobj_lock(safeobj);
+ printf("threadfunc_safeobj1/// %d\n", ret);
+
+ return 0;
+}
+
+void *threadfunc_safeobj2(void *parm)
+{
+ mysafeobj_t *safeobj = (mysafeobj_t *)parm;
+ int ret = 0;
+
+ so_mutex_count++;
+ ret = tsk_safeobj_lock(safeobj);
+ printf("threadfunc_safeobj2/// %d\n", ret);
+
+ return 0;
+}
+
+/* test safeobject */
+void test_safeobject()
+{
+ mysafeobj_t* obj = calloc(1, sizeof(mysafeobj_t));
+ void* tid[2] = {0, 0};
+ int i;
+
+ printf("test_safeobject//\n");
+
+ tsk_safeobj_init(obj);
+
+ //assert(!tsk_safeobj_lock(obj));
+
+ tsk_thread_create(&tid[0], threadfunc_safeobj1, obj);
+ tsk_thread_create(&tid[1], threadfunc_safeobj2, obj);
+
+ /* VERY BAD */
+ while(so_mutex_count<2);
+ for(i=0;i<10000000;i++);
+
+ /*assert(!*/tsk_safeobj_unlock(obj)/*)*/;
+ /*assert(!*/tsk_safeobj_unlock(obj)/*)*/;
+
+ tsk_thread_join(&tid[0]);
+ tsk_thread_join(&tid[1]);
+
+ tsk_safeobj_deinit(obj);
+ tsk_free((void**)&obj);
+}
+
+#endif /* _TEST_SAFEOBJ_H_ */
diff --git a/tinySAK/test/test_semaphore.h b/tinySAK/test/test_semaphore.h
new file mode 100644
index 0000000..977dd9f
--- /dev/null
+++ b/tinySAK/test/test_semaphore.h
@@ -0,0 +1,73 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_SEMAPHORE_H_
+#define _TEST_SEMAPHORE_H_
+
+void *threadfunc_semaphore1(void *parm)
+{
+ tsk_semaphore_handle_t *semaphore = (tsk_semaphore_handle_t *)parm;
+ int ret = 0;
+
+ printf("threadfunc_semaphore1/// START %d\n", ret);
+ ret = tsk_semaphore_decrement(semaphore);
+ printf("threadfunc_semaphore1/// STOP %d\n", ret);
+
+ return 0;
+}
+
+void *threadfunc_semaphore2(void *parm)
+{
+ tsk_semaphore_handle_t *semaphore = (tsk_semaphore_handle_t *)parm;
+ int ret = 0;
+
+ printf("threadfunc_semaphore2/// START %d\n", ret);
+ ret = tsk_semaphore_decrement(semaphore);
+ printf("threadfunc_semaphore2/// STOP %d\n", ret);
+
+ return 0;
+}
+
+/* Pthread semaphore */
+void test_semaphore()
+{
+ tsk_semaphore_handle_t *semaphore = tsk_semaphore_create();
+ void* tid[2] = {0,0};
+
+ printf("test_semaphore//\n");
+
+ tsk_thread_create(&tid[0], threadfunc_semaphore1, semaphore);
+ tsk_thread_create(&tid[1], threadfunc_semaphore2, semaphore);
+
+ tsk_thread_sleep(1000);
+
+ assert(!tsk_semaphore_increment(semaphore));
+ assert(!tsk_semaphore_increment(semaphore));
+
+ tsk_thread_sleep(1000);
+
+ tsk_thread_join(&tid[0]);
+ tsk_thread_join(&tid[1]);
+
+ tsk_semaphore_destroy(&semaphore);
+}
+
+#endif /* _TEST_SEMAPHORE_H_ */
diff --git a/tinySAK/test/test_sha1.h b/tinySAK/test/test_sha1.h
new file mode 100644
index 0000000..5e2ef78
--- /dev/null
+++ b/tinySAK/test/test_sha1.h
@@ -0,0 +1,96 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_SHA1_H_
+#define _TEST_SHA1_H_
+
+struct sha1_result
+{
+ const char* msg;
+ const char* xres;
+};
+
+struct sha1_result msgs[] =
+{
+ { "", "da39a3ee5e6b4b0d3255bfef95601890afd80709" },
+ { "The quick brown fox jumps over the lazy dog", "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12" },
+ { "The quick brown fox jumps over the lazy cog", "de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3" },
+};
+
+void test_sha1()
+{
+ size_t i;
+ tsk_sha1string_t sha1result;
+
+ for(i=0; i< sizeof(msgs)/sizeof(struct sha1_result); i++)
+ {
+ tsk_sha1compute(msgs[i].msg, strlen(msgs[i].msg), &sha1result);
+ if(tsk_striequals(msgs[i].xres, sha1result))
+ {
+ TSK_DEBUG_INFO("[SHA1-%d] ==> OK", i);
+ }
+ else
+ {
+ TSK_DEBUG_INFO("[SHA1-%d] ==> NOK", i);
+ }
+ }
+}
+
+struct hmac_sha1_result
+{
+ const char* msg;
+ const char* key;
+ const char* xres;
+};
+
+struct hmac_sha1_result hmac_sha1_msgs[] =
+{
+ { "Hi There", "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", "b617318655057264e28bc0b6fb378c8ef146be00" },
+ { "what do ya want for nothing?", "Jefe", "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79" },
+ { "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "125d7342b9ac11cd91a39af48aa17b4f63f175d3" },
+ { "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd", "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "4c9007f4026250c6bc8414f9bf50c86c2d7235da" },
+ { "Test With Truncation", "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c", "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04" },
+ { "Test Using Larger Than Block-Size Key - Hash Key First", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "aa4ae5e15272d00e95705637ce8a3b55ed402112" },
+ { "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "e8e99d0f45237d786d6bbaa7965c7808bbff1a91" },
+
+};
+
+void test_hmac_sha1()
+{
+ size_t i;
+ tsk_sha1string_t sha1result;
+
+ for(i=0; i< sizeof(hmac_sha1_msgs)/sizeof(struct hmac_sha1_result); i++)
+ {
+ hmac_sha1_compute((const uint8_t*)hmac_sha1_msgs[i].msg, strlen(hmac_sha1_msgs[i].msg), hmac_sha1_msgs[i].key, strlen(hmac_sha1_msgs[i].key), &sha1result);
+ if(tsk_striequals(hmac_sha1_msgs[i].xres, sha1result))
+ {
+ TSK_DEBUG_INFO("[SHA1-%d] ==> OK", i);
+ }
+ else
+ {
+ TSK_DEBUG_INFO("[SHA1-%d] ==> NOK", i);
+ }
+ }
+}
+
+
+#endif /* _TEST_SHA1_H_ */
diff --git a/tinySAK/test/test_strings.h b/tinySAK/test/test_strings.h
new file mode 100644
index 0000000..a6d1b10
--- /dev/null
+++ b/tinySAK/test/test_strings.h
@@ -0,0 +1,75 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_STRINGS_H_
+#define _TEST_STRINGS_H_
+
+/* test string manipulation */
+void test_strings()
+{
+ char* str = tsk_null;
+ int index;
+
+ /* IndexOf */
+ index = tsk_strindexOf("C:\\test.zip", 5, "\\");
+ index = tsk_strindexOf("C:\\test.zip", tsk_strlen("C:\\test.zip"), "abc");
+ index = tsk_strLastIndexOf("C:\\my dirctory\\test.zip", tsk_strlen("C:\\my dirctory\test.zip"), "\\");
+ index = tsk_strLastIndexOf("C:\\my dirctory\\test.zip", tsk_strlen("C:\\my dirctory\test.zip"), ".");
+
+ /* LastIndexOf */
+
+ /* concatenation */
+ tsk_strcat(&str, " first ");
+ printf("test_strings/// strcat=%s\n", str);
+
+ /* Trim Right */
+ tsk_strtrim_right(&str);
+ printf("test_strings/// trim_right=%s\n", str);
+
+ tsk_strcat(&str, "second");
+ printf("test_strings/// strcat=%s\n", str);
+
+ /* Trim Left */
+ tsk_strtrim_left(&str);
+ printf("test_strings/// trim_left=%s\n", str);
+
+ tsk_free((void**)&str);
+
+ /* sprintf */
+ tsk_sprintf(&str, " \n\t%s %s\r ", "first", "second");
+ printf("test_strings/// strcat=\"%s\"\n", str);
+
+ /* Trim Both */
+ tsk_strtrim_both(&str);
+ printf("test_strings/// trim_both=%s\n", str);
+
+ /* Quote */
+ tsk_strquote(&str);
+ printf("test_strings/// quote=%s\n", str);
+
+ /* Unquote */
+ tsk_strunquote(&str);
+ printf("test_strings/// unquote=%s\n", str);
+
+ tsk_free((void**)&str);
+}
+
+#endif /* _TEST_STRINGS_H_ */
diff --git a/tinySAK/test/test_threads.h b/tinySAK/test/test_threads.h
new file mode 100644
index 0000000..166765b
--- /dev/null
+++ b/tinySAK/test/test_threads.h
@@ -0,0 +1,48 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+
+
+#ifndef _TEST_THREADS_H_
+#define _TEST_THREADS_H_
+
+
+void* MyThreadFunction(void *arg)
+{
+ printf("arg=%d", *((int*)arg));
+ return tsk_null;
+}
+
+void test_threads()
+{
+ void* tid[1] = {tsk_null}; // thread id
+ int arg = 112; // arg to pass to the function
+
+ printf("test_threads//\n");
+
+ // create the thread
+ tsk_thread_create(&tid[0], MyThreadFunction, &arg);
+
+ // join the thread
+ tsk_thread_join(&(tid[0]));
+}
+
+#endif /* _TEST_THREADS_H_ */
diff --git a/tinySAK/test/test_timer.h b/tinySAK/test/test_timer.h
new file mode 100644
index 0000000..2b7ab4f
--- /dev/null
+++ b/tinySAK/test/test_timer.h
@@ -0,0 +1,104 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_TIMER_H_
+#define _TEST_TIMER_H_
+typedef struct test_timer_s
+{
+ tsk_timer_id_t id;
+ uint64_t timeout;
+ const char *arg;
+}
+test_timer_t;
+
+test_timer_t timers[] =
+{
+ {0, 2000, "3"},
+ {1, 2500, "4"},
+ {2, 500, "1"},
+ {3, 1000, "2"},
+ {4, 1000, "2"},
+ {5, 0, "0"},
+ {6, 10000, "6"},
+ {7, 3000, "5"},
+ {8, 2500, "4"},
+};
+
+static int test_timer_callback(const void* arg, tsk_timer_id_t timer_id)
+{
+ // Do quick job
+ printf("test_timer - id=%llu and arg=%s//\n", timer_id, arg);
+ return 0;
+}
+
+void test_global_timer()
+{
+ size_t i;
+ tsk_timer_mgr_global_ref();
+
+ // for test: start it two times
+ tsk_timer_mgr_global_start();
+ tsk_timer_mgr_global_start();
+
+ for(i=0; i<sizeof(timers)/sizeof(test_timer_t); ++i){
+ timers[i].id = tsk_timer_mgr_global_schedule(timers[i].timeout, test_timer_callback, timers[i].arg);
+ }
+
+ tsk_timer_mgr_global_cancel(timers[6].id);
+ tsk_timer_mgr_global_cancel(timers[2].id);
+
+ tsk_thread_sleep(4000);
+
+ // for test: stop it only one time
+ tsk_timer_mgr_global_stop();
+ tsk_timer_mgr_global_stop();
+
+ tsk_timer_mgr_global_unref();
+}
+
+void test_single_timer()
+{
+ size_t i;
+ tsk_timer_manager_handle_t *handle = tsk_timer_manager_create();
+ printf("test_timer//\n");
+
+ tsk_timer_manager_start(handle);
+
+ for(i=0; i<sizeof(timers)/sizeof(test_timer_t); ++i){
+ timers[i].id = tsk_timer_manager_schedule(handle, timers[i].timeout, test_timer_callback, timers[i].arg);
+ }
+
+ tsk_timer_manager_cancel(handle, timers[6].id);
+ tsk_timer_manager_cancel(handle, timers[2].id);
+
+ tsk_thread_sleep(4000);
+
+ /* Stops and frees the timer manager */
+ TSK_OBJECT_SAFE_FREE(handle);
+}
+
+void test_timer()
+{
+ //test_single_timer();
+ test_global_timer();
+}
+
+#endif /* _TEST_TIMER_H_ */
diff --git a/tinySAK/test/test_url.h b/tinySAK/test/test_url.h
new file mode 100644
index 0000000..76aa456
--- /dev/null
+++ b/tinySAK/test/test_url.h
@@ -0,0 +1,43 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_URL_H_
+#define _TEST_URL_H_
+
+/* url encoding/decoding */
+void test_url()
+{
+ const char *url = "http://xcap.example.org/resource-lists/users/sip:RCSUser@example.org/index/~~/resource-lists/list%5B@name=%22rcs%22%5D";
+ char *str1, *str2;
+
+ /*decode url*/
+ str1 = tsk_url_decode(url);
+ printf("test_url/// decoded url:%s\n", str1);
+
+ /*encode url*/
+ str2 = tsk_url_encode(str1);
+ printf("test_url/// encoded url:%s\n", str2);
+
+ tsk_free((void**)&str1);
+ tsk_free((void**)&str2);
+}
+
+#endif /* _TEST_URL_H_ */
diff --git a/tinySAK/test/test_uuid.h b/tinySAK/test/test_uuid.h
new file mode 100644
index 0000000..b02db33
--- /dev/null
+++ b/tinySAK/test/test_uuid.h
@@ -0,0 +1,35 @@
+/*
+* Copyright (C) 2009 Mamadou Diop.
+*
+* Contact: Mamadou Diop <diopmamadou@yahoo.fr>
+*
+* This file is part of Open Source Doubango Framework.
+*
+* DOUBANGO 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.
+*
+* DOUBANGO 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 DOUBANGO.
+*
+*/
+#ifndef _TEST_UUID_H_
+#define _TEST_UUID_H_
+
+void test_uuid()
+{
+ tsk_uuidstring_t uuid;
+
+ tsk_uuidgenerate(&uuid);
+
+ TSK_DEBUG_INFO("Generated UUID: %s", uuid);
+}
+
+#endif /* _TEST_UUID_H_ */
+
OpenPOWER on IntegriCloud