--- /dev/null
+#******************************************************************
+#
+# Copyright 2015 Samsung Electronics All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('env')
+import os
+import os.path
+catest_env = env.Clone()
+
+src_dir = catest_env.get('SRC_DIR')
+
+######################################################################
+# Build flags
+######################################################################
+catest_env.PrependUnique(CPPPATH = [
+ '../../ocsocket/include',
+ '../../logger/include',
+ '../../stack/include',
+ '../../ocmalloc/include',
+ '../../extlibs/cjson',
+ '../../../oc_logger/include',
+ '../../../../extlibs/gtest/gtest-1.7.0/include'
+ ])
+
+tmplist = catest_env['LINKFLAGS'][:]
+if '-lpthread' in tmplist:
+ tmplist.remove('-lpthread')
+ catest_env.Replace(LINKFLAGS = tmplist)
+
+catest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+catest_env.AppendUnique(LIBS = ['pthread'])
+catest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+catest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
+catest_env.PrependUnique(LIBS = ['m',
+ 'octbstack',
+ 'oc_logger',
+ 'connectivity_abstraction',
+ 'coap',
+ 'gtest',
+ 'gtest_main'])
+
+if env.get('SECURED') == '1':
+ catest_env.AppendUnique(LIBS = ['tinydtls'])
+catest_env.ParseConfig('pkg-config --libs glib-2.0');
+
+if not env.get('RELEASE'):
+ catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+catests = catest_env.Program('catests', ['catests.cpp',
+ 'caprotocolmessagetest.cpp'])
+
+Alias("test", [catests])
+
+env.AppendTarget('test')
+if env.get('TEST') == '1':
+ target_os = env.get('TARGET_OS')
+ if target_os == 'linux':
+ out_dir = env.get('BUILD_DIR')
+ result_dir = env.get('BUILD_DIR') + '/test_out/'
+ if not os.path.isdir(result_dir):
+ os.makedirs(result_dir)
+ catest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
+ catest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
+ catest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
+ ut = catest_env.Command ('ut', None, out_dir + '/resource/csdk/connectivity/test/catests')
+ AlwaysBuild ('ut')
--- /dev/null
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#include "gtest/gtest.h"
+
+#include <pthread.h>
+
+/**
+ * Simple holder of work-arounds for link-time issues.
+ */
+void workaroundHook()
+{
+ pthread_key_t key = {0};
+ int ret = pthread_key_create(&key, NULL);
+ if (!ret)
+ {
+ void *ptr = pthread_getspecific(key); // should return NULL
+ ret = pthread_setspecific(key, &ptr);
+ if (ret)
+ {
+ // Something went wrong. Since this is a stub, we don't care.
+ }
+
+ pthread_key_delete(key);
+ }
+}
+
+
+TEST(BaseTest, WorldIsSane)
+{
+ workaroundHook();
+
+ EXPECT_EQ(1 + 1, 2);
+
+ int a = 1;
+ int b = 5;
+
+ EXPECT_GT(b, a);
+}