Commit d93227e6 authored by Erich Keane's avatar Erich Keane

Fix Android build failures, enable random unit tests

It was discovered that the ocrandom uuid changes broke the android
build.  This is because Android, despite being an incomplete linux
implementation, defines __linux__.  This patch fixes that, and properly
enables the ocrandom unit tests.

Additionally, the OC_WIFI/OC_ETHERNET removals weren't propogated
properly to the android build, this patch does that in order to fix the
build.

Change-Id: Iabfeb704d046fbadf1fd368259d0e96ca1e74d90
Signed-off-by: default avatarErich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1020Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMandeep Shetty <mandeep.shetty@intel.com>
Reviewed-by: default avatarVijay Kesavan <vijay.s.kesavan@intel.com>
parent 7333523f
......@@ -128,9 +128,9 @@ public:
{
switch (type) {
case 0:
return OCConnectivityType::OC_ETHERNET;
return OCConnectivityType::OC_IPV4;
case 1:
return OCConnectivityType::OC_WIFI;
return OCConnectivityType::OC_IPV6;
case 2:
return OCConnectivityType::OC_EDR;
case 3:
......@@ -227,4 +227,4 @@ public:
return "";
}
}
};
\ No newline at end of file
};
......@@ -96,7 +96,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -138,7 +138,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPresenceHandle presenceHandle = OcPlatform.subscribePresence(
resource.getHost(),
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
presenceListener
);
......@@ -168,7 +168,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//server
......@@ -314,7 +314,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource(null,
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -477,7 +477,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -643,7 +643,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -747,7 +747,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -925,7 +925,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -993,7 +993,7 @@ public class SmokeTest extends InstrumentationTestCase {
OcPlatform.getDeviceInfo(
"",
OcPlatform.WELL_KNOWN_QUERY + "/d",
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
deviceFoundListener);
//wait for onDeviceFound event
......@@ -1093,7 +1093,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener1);
//wait for onResourceFound event to find 3 registered resources
......@@ -1106,7 +1106,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener3);
//wait for onResourceFound event to find 1 collection resources
......@@ -1118,7 +1118,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener2);
//wait for onResourceFound event to find 2 resources
......@@ -1130,7 +1130,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener4);
//wait for onResourceFound event to find 3 registered resources
......@@ -1145,7 +1145,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener6);
//wait for onResourceFound event to find 1 collection resources
......@@ -1156,7 +1156,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener5);
//wait for onResourceFound event to find 1 collection resources
......@@ -1240,12 +1240,12 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType1,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType2,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -1289,7 +1289,7 @@ public class SmokeTest extends InstrumentationTestCase {
OcResource resourceProxy = OcPlatform.constructResourceObject(
resource.getHost(),
resource.getUri(),
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resource.isObservable(),
resource.getResourceTypes(),
resource.getResourceInterfaces());
......@@ -1319,7 +1319,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -1346,7 +1346,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -1518,7 +1518,7 @@ public class SmokeTest extends InstrumentationTestCase {
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
OcConnectivityType.WIFI,
OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
......@@ -1560,4 +1560,4 @@ public class SmokeTest extends InstrumentationTestCase {
private OcRepresentation getRepresentation() {
return getRepresentation(74);
}
}
\ No newline at end of file
}
......@@ -25,8 +25,8 @@ package org.iotivity.base;
import java.security.InvalidParameterException;
public enum OcConnectivityType {
ETHERNET(0),
WIFI (1),
IPV4 (0),
IPV6 (1),
EDR (2),
LE (3),
ALL (4),
......
......@@ -216,8 +216,8 @@ public final class OcPlatform {
* If empty, performs multicast resource discovery query
* @param resourceUri name of the resource. If null or empty, performs search for all
* resource names
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param onResourceFoundListener Handles events, success states and failure states.
* @throws OcException
*/
......@@ -248,8 +248,8 @@ public final class OcPlatform {
* If empty, performs multicast resource discovery query
* @param resourceUri name of the resource. If null or empty, performs search for all
* resource names
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param onResourceFoundListener Handles events, success states and failure states.
* @param qualityOfService the quality of communication
* @throws OcException
......@@ -281,8 +281,8 @@ public final class OcPlatform {
*
* @param host Host IP Address. If null or empty, Multicast is performed.
* @param deviceUri Uri containing address to the virtual device
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param onDeviceFoundListener Handles events, success states and failure states.
* @throws OcException
*/
......@@ -311,8 +311,8 @@ public final class OcPlatform {
*
* @param host Host IP Address. If null or empty, Multicast is performed.
* @param deviceUri Uri containing address to the virtual device
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param onDeviceFoundListener Handles events, success states and failure states.
* @param qualityOfService the quality of communication
* @throws OcException
......@@ -600,8 +600,8 @@ public final class OcPlatform {
* server adds/removes/alters a resource, starts or is intentionally stopped
*
* @param host The IP address/addressable name of the server to subscribe to
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param onPresenceListener listener that will receive notifications/subscription events
* @return a handle object that can be used to identify this subscription request. It can be
* used to unsubscribe from these events in the future
......@@ -630,8 +630,8 @@ public final class OcPlatform {
*
* @param host The IP address/addressable name of the server to subscribe to
* @param resourceType a resource type specified as a filter for subscription events.
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param onPresenceListener listener that will receive notifications/subscription events
* @return a handle object that can be used to identify this subscription request. It can be
* used to unsubscribe from these events in the future
......@@ -687,8 +687,8 @@ public final class OcPlatform {
* @param uri the rest of the resource's URI that will permit messages to be
* properly routed.
* Example: /a/light
* @param connectivityType a type of connectivity indicating the interface. Example: WIFI,
* ETHERNET, ALL
* @param connectivityType a type of connectivity indicating the interface. Example: IPV4,
* IPV6, ALL
* @param isObservable a boolean containing whether the resource supports observation
* @param resourceTypeList a collection of resource types implemented by the resource
* @param interfaceList a collection of interfaces that the resource supports/implements
......@@ -774,4 +774,4 @@ public final class OcPlatform {
"OcPlatform.Configure before any other API calls are permitted");
}
}
}
\ No newline at end of file
}
......@@ -26,7 +26,7 @@
#include "ocrandom.h"
#include <stdio.h>
#if defined(__linux__) || defined(__APPLE__)
#if !defined(__ANDROID__) && (defined(__linux__) || defined(__APPLE__))
#include <uuid/uuid.h>
#endif
......@@ -162,11 +162,7 @@ OCRandomUuidResult OCGenerateUuid(uint8_t uuid[UUID_SIZE])
{
return RAND_UUID_INVALID_PARAM;
}
#if defined(__linux__) || defined(__APPLE__)
// note: uuid_t is typedefed as unsigned char[16] on linux/apple
uuid_generate(uuid);
return RAND_UUID_OK;
#elif defined(__ANDROID__)
#if defined(__ANDROID__)
char uuidString[UUID_STRING_SIZE];
int8_t ret = OCGenerateUuidString(uuidString);
......@@ -196,6 +192,10 @@ OCRandomUuidResult OCGenerateUuid(uint8_t uuid[UUID_SIZE])
uuid[14] = parseUuidPart(&uuidString[32]);
uuid[15] = parseUuidPart(&uuidString[34]);
return RAND_UUID_OK;
#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__APPLE__))
// note: uuid_t is typedefed as unsigned char[16] on linux/apple
uuid_generate(uuid);
return RAND_UUID_OK;
#else
// Fallback for all platforms is filling the array with random data
......@@ -210,19 +210,7 @@ OCRandomUuidResult OCGenerateUuidString(char uuidString[UUID_STRING_SIZE])
{
return RAND_UUID_INVALID_PARAM;
}
#if defined(__linux__) || defined(__APPLE__)
uint8_t uuid[UUID_SIZE];
int8_t ret = OCGenerateUuid(uuid);
if(ret != 0)
{
return ret;
}
uuid_unparse_lower(uuid, uuidString);
return RAND_UUID_OK;
#elif defined(__ANDROID__)
#if defined(__ANDROID__)
int32_t fd = open("/proc/sys/kernel/random/uuid", O_RDONLY);
if(fd > 0)
{
......@@ -250,6 +238,18 @@ OCRandomUuidResult OCGenerateUuidString(char uuidString[UUID_STRING_SIZE])
close(fd);
return RAND_UUID_READ_ERROR;
}
#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__APPLE__))
uint8_t uuid[UUID_SIZE];
int8_t ret = OCGenerateUuid(uuid);
if(ret != 0)
{
return ret;
}
uuid_unparse_lower(uuid, uuidString);
return RAND_UUID_OK;
#else
uint8_t uuid[UUID_SIZE];
OCGenerateUuid(uuid);
......
#******************************************************************
#
# Copyright 2014 Intel Mobile Communications GmbH 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
randomtest_env = env.Clone()
src_dir = randomtest_env.get('SRC_DIR')
######################################################################
# Build flags
######################################################################
randomtest_env.PrependUnique(CPPPATH = [
'../include',
'../../logger/include',
'../../ocmalloc/include',
'../../../oc_logger/include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
])
randomtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
randomtest_env.AppendUnique(LIBS = ['-lpthread'])
randomtest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
randomtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
randomtest_env.PrependUnique(LIBS = ['m',
'octbstack',
'uuid',
'gtest',
'gtest_main'])
if env.get('LOGGING'):
randomtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
######################################################################
# Source files and Targets
######################################################################
randomtests = randomtest_env.Program('randomtests', ['linux/randomtest.cpp'])
Alias("test", [randomtests])
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)
randomtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
randomtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
randomtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = randomtest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_random_test.memcheck ' + out_dir + 'resource/csdk/ocrandom/test/randomtests')
AlwaysBuild ('ut')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment