Adding C++ UB Unit Tests AND C++ UB Samples to buildScript.mk makefile.
authorJoseph Morrow <joseph.l.morrow@intel.com>
Fri, 17 Oct 2014 16:54:18 +0000 (12:54 -0400)
committerWilliam Dieter <william.r.dieter@intel.com>
Fri, 24 Oct 2014 19:05:54 +0000 (12:05 -0700)
This change will be reflected by calling make on any 'Linux' "all" target
in the buildScript.mk makefile. This also contains refactor from UB & TB
to Rich & Lite, respectively.

Change-Id: Ie9c04c28c3f85bf5ffda29c6591cbd2eaeaac1e8

README
buildScript.mk
unittests/README
unittests/makefile

diff --git a/README b/README
index b042e2b..3c6e6ac 100644 (file)
--- a/README
+++ b/README
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 ===============================================================================
-==                      UB Stack & TB Stack                                  ==
+==                      Rich Stack & Lite Stack                              ==
 ===============================================================================
 
-The OIC-RESOURCE repository contains two SDKs with underlying code
-(i.e. "stack"). The two SDKs are referred to as "UB SDK" (or "C++ SDK") and "TB
-SDK" (or "C SDK"). The associated stacks are referred to as "UB Stack" (or "C++
-Stack") and "TB Stack" (or "C Stack"), respectively. The UB Stack-SDK pair
-requires that the TB Stack-SDK pair is built under it.
+The OIC-RESOURCE repository (referred as "<oic-resource>") contains two SDKs
+with underlying code (i.e. "stack"). The two SDKs are referred to as "Rich SDK"
+(or "C++ SDK") and "Lite SDK" (or "C SDK"). The associated stacks are referred
+to as "Rich Stack" (or "C++ Stack") and "Lite Stack" (or "C Stack"),
+respectively. The Rich Stack-SDK pair requires that the Lite Stack-SDK pair is
+built under it.
 
 For a list of artifact locations for all possible build processes in the
 OIC-RESOURCE repository, please refer to:
@@ -34,48 +35,78 @@ OIC-RESOURCE repository, please refer to:
 
 ===============================================================================
 
-The UB Stack is intended ONLY for Linux Ubuntu 12.04 operating system.
-To build UB Stack, please follow these requirements:
+The Rich Stack is intended ONLY for Linux Ubuntu 12.04 operating system.
+To build Rich Stack, please follow these requirements:
 - GCC compiler version is 4.6
 - Pre-install the "gnu-libc" libraries package.
-- The OIC-UTILITIES repository must be a sibling directory to the OIC-RESOURCE
-  repository.
-- You have pre-built the TB Stack for Linux Ubuntu 12.04.
+- You have pre-built the Lite Stack for Linux Ubuntu 12.04.
+- You have installed and pre-built Boost 1.54.
+- To compile Rich Unit Tests, you must have Google Test 1.7.0 and must also
+  create/append "local.properties" file at <oic-resource>/csdk/ with the
+  following specified:
 
-The TB Stack is intended ONLY for Linux Ubuntu 12.04, Arduino ATMega 2560 with
+  GTEST_DIR=<gtest-1.7.0>
+
+The Lite Stack is intended ONLY for Linux Ubuntu 12.04, Arduino ATMega 2560 with
 Arduino Framework 1.0.5, and Arduino Due with Arduino Framework 1.5.7.
 Tip: Use Cutecom in Ubuntu 12.04 to view logs from Arduino ATMega 2560 and
 Arduino Due.
 
-To build TB Stack, please follow these requirements for Linux Ubuntu 12.04:
+To build Lite Stack, please follow these requirements for Linux Ubuntu 12.04:
 - GCC compiler version is 4.6
 - Pre-install the "gnu-libc" libraries package.
-- The OIC-UTILITIES repository must be a sibling directory to the OIC-RESOURCE
-  repository.
 
-To build TB Stack, please follow these requirements for Arduino ATMega 2560:
+To build Lite Stack, please follow these requirements for Arduino ATMega 2560:
+- Arduino Framework 1.0.5 is installed. (Newer versions of the Arduino
+  Framework for Arduino ATMega 2560 have not been tested.)
 - AVR-GCC compiler version is 4.5.3 (Distributed with Arduino 1.0.5, no further
-  action necessary if framework was obtained from http://www.arduino.cc. Note:
-  Frameworks obtained from apt-get have had different compiler versions.)
+  action necessary if framework was obtained from
+  http://arduino.cc/en/Main/OldSoftwareReleases. Note: Frameworks obtained from
+  apt-get have had different compiler versions.)
 - Unzip the Time Library from here to your Arduino Directory Structure:
   http://playground.arduino.cc/code/time
-- The OIC-UTILITIES repository must be a sibling directory to the OIC-RESOURCE
-  repository.
-- Apply patches at OIC-UTILITIES/tb/ to your Arduino Directory Structure at
-  locations <Arduino 1.0.5>/libraries/Ethernet &
-  <Arduino 1.0.5>/libraries/Ethernet/utility/.
-
-To build TB Stack, please follow these requirements for Arduino Due:
+- Apply patch "arduino-1.0.5_linux.patch" at
+  <oic-resource>/tools/arduino/patches to your Arduino Directory Structure at
+  location <Arduino 1.0.5>.
+- Create/Append "local.properties" file at location
+  <oic-resource>/resource/csdk/ with the following specified:
+
+  ARDUINO_DIR := <arduino-1.0.5>
+  ARDUINO_TOOLS_DIR := $(ARDUINO_DIR)/hardware/tools/avr/bin
+
+To build Lite Stack, please follow these requirements for Arduino Due:
+- Arduino Framework 1.5.7 is installed. (Newer versions of the Arduino
+  Framework for Arduino Due have not been tested.)
 - AVR-GCC compiler version is 4.8.3 (Distributed with Arduino 1.5.7, no further
-  action necessary if framework was obtained from http://www.arduino.cc. Note:
-  Frameworks obtained from apt-get have had different compiler versions.)
+  action necessary if framework was obtained from
+  http://arduino.cc/en/Main/OldSoftwareReleases. Note: Frameworks obtained from
+  apt-get have had different compiler versions.)
 - Unzip the Time Library from here to your Arduino Directory Structure:
   http://www.pjrc.com/teensy/td_libs_Time.html
-- The OIC-UTILITIES repository must be a sibling directory to the OIC-RESOURCE
-  repository.
-- Apply patches at OIC-UTILITIES/tb/ to your Arduino Directory Structure at
-  locations <Arduino 1.5.7>/libraries/Ethernet &
-  <Arduino 1.5.7>/libraries/Ethernet/utility/.
+- Apply patch "arduino-1.5.7_linux.patch" at
+  <oic-resource>/tools/arduino/patches to your Arduino Directory Structure at
+  location <Arduino 1.5.7>.
+- Create/Append "local.properties" file at location
+  <oic-resource>/resource/csdk/ with the following specified:
+
+  ARDUINO_DIR := <arduino-1.5.7>
+  ARDUINO_TOOLS_DIR := $(ARDUINO_DIR)/hardware/tools/avr/bin
+
+Note: If you are building Unit Tests for Linux, building for Arduino Mega, and
+building for Arduino Due you may find it useful to set the "local.properties"
+file to look like this:
+
+GTEST_DIR=<gtest-1.7.0>
+
+ifeq ($(PLATFORM), arduinomega)
+       #Location of arduino sdk for Arduino Mega
+       ARDUINO_DIR := <arduino-1.0.5>
+       ARDUINO_TOOLS_DIR := $(ARDUINO_DIR)/hardware/tools/avr/bin
+else
+       #Location of arduino sdk for Arduino Due
+       ARDUINO_DIR := <arduino-1.5.7>
+       ARDUINO_TOOLS_DIR := $(ARDUINO_DIR)/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin
+endif
 
 ===============================================================================
 
@@ -88,11 +119,12 @@ NOTE: 'GNU Make' is required to utilize the build script at location:
 == All Targets - Linux, ATMega & Due ==
 =======================================
 
-- All Modules, including OCICUC, in Release & Debug (TB Stack, TB Unit Tests,
-TB Examples, UB Stack, UB Examples, UB OCICUC) for linux, Arduino ATMega 2560
-with Ethernet Shield, Arduino ATMega ATMega 2560 with WiFi Shield, Arduino
-Due with Ethernet Shield and Arduino Due with WiFi Shield:
-(This will be what is used on the Build Server(s) to limit regression.)
+- All Modules, including OCICUC, in Release & Debug (Lite Stack, Lite Unit
+  Tests, Lite Examples, Rich Stack, Rich Unit Tests, Rich Examples, Rich
+  OCICUC) for linux, Arduino ATMega 2560 with Ethernet Shield, Arduino ATMega
+  ATMega 2560 with WiFi Shield, Arduino Due with Ethernet Shield and Arduino
+  Due with WiFi Shield:
+  (This will be what is used on the Build Server(s) to limit regression.)
 
        make -f buildScript.mk all_dev
 
@@ -100,13 +132,14 @@ Due with Ethernet Shield and Arduino Due with WiFi Shield:
 == All Targets - Linux & ATMega 2560 ==
 =======================================
 
-- All Modules in Release (TB Stack, TB Unit Tests, TB Examples, UB Stack, UB
-Examples) for Linux & Arduino ATMega 2560 with Ethernet Shield:
+- All Modules in Release (Lite Stack, Lite Unit Tests, Lite Examples, Rich
+  Stack, Rich Unit Tests, Rich Examples) for Linux & Arduino ATMega 2560 with
+  Ethernet Shield:
 
        make -f buildScript.mk all
 
-- All Modules in Debug (TB Stack, TB Unit Tests, TB Examples, UB Stack, UB
-Examples) for Linux & Arduino ATMega 2560 with Ethernet Shield:
+- All Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples, Rich Stack,
+  Rich Examples) for Linux & Arduino ATMega 2560 with Ethernet Shield:
 
        make -f buildScript.mk all_debug
 
@@ -114,13 +147,14 @@ Examples) for Linux & Arduino ATMega 2560 with Ethernet Shield:
 ==     All Targets - Linux & Due     ==
 =======================================
 
-- All Modules in Release (TB Stack, TB Unit Tests, TB Examples, UB Stack, UB
-Examples) for Linux & Arduino Due with Ethernet Shield:
+- All Modules in Release (Lite Stack, Lite Unit Tests, Lite Examples, Rich
+  Stack, Rich Unit Tests, Rich Examples) for Linux & Arduino Due with Ethernet
+  Shield:
 
        make -f buildScript.mk complement
 
-- All Modules in Debug (TB Stack, TB Unit Tests, TB Examples, UB Stack, UB
-Examples) for Linux & Arduino Due with Ethernet Shield:
+- All Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples, Rich Stack,
+  Rich Unit Tests, Rich Examples) for Linux & Arduino Due with Ethernet Shield:
 
        make -f buildScript.mk complement_debug
 
@@ -128,38 +162,38 @@ Examples) for Linux & Arduino Due with Ethernet Shield:
 ==     All Targets - Linux Only      ==
 =======================================
 
-- All Modules, without OCICUC, in Release (TB Stack, TB Unit Tests,
-TB Examples, UB Stack, UB Examples) for linux:
+- All Modules, without OCICUC, in Release (Lite Stack, Lite Unit Tests, Lite
+  Examples, Rich Stack, Rich Unit Tests, Rich Examples) for linux:
 
        make -f buildScript.mk linux
 
-- All Modules, without OCICUC, in Debug (TB Stack, TB Unit Tests,
-TB Examples, UB Stack, UB Examples) for linux:
+- All Modules, without OCICUC, in Debug (Lite Stack, Lite Unit Tests, Lite
+  Examples, Rich Stack, Rich Unit Tests, Rich Examples) for linux:
 
        make -f buildScript.mk linux_debug
 
-- All UB Stack Modules in Release, without OCICUC, (TB Stack, UB Stack, UB
-Examples) for Linux:
+- All Rich Stack Modules in Release, without OCICUC, (Lite Stack, Rich Stack,
+  Rich Unit Tests, Rich Examples) for Linux:
 
        make -f buildScript.mk linux_ub
 
-- All UB Stack Modules in Debug, without OCICUC, (TB Stack, UB Stack, UB
-Examples) for Linux:
+- All Rich Stack Modules in Debug, without OCICUC, (Lite Stack, Rich Stack,
+  Rich Unit Tests, Rich Examples) for Linux:
 
        make -f buildScript.mk linux_ub_debug
 
-- All UB Stack Modules, including OCICUC, in Release & Debug (TB Stack,
-UB Stack, UB Examples, UB OCICUC) for linux:
+- All Rich Stack Modules, including OCICUC, in Release & Debug (Lite Stack,
+  Rich Stack, Rich Unit Tests, Rich Examples, Rich OCICUC) for linux:
 
        make -f buildScript.mk linux_ub_dev
 
-- All TB Stack Modules in Release (TB Stack, TB Unit Tests,
-TB Examples) for Linux:
+- All Lite Stack Modules in Release (Lite Stack, Lite Unit Tests, Lite
+  Examples) for Linux:
 
        make -f buildScript.mk linux_tb
 
-- All TB Stack Modules in Debug (TB Stack, TB Unit Tests,
-TB Examples) for Linux:
+- All Lite Stack Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples)
+  for Linux:
 
        make -f buildScript.mk linux_tb_debug
 
@@ -167,23 +201,23 @@ TB Examples) for Linux:
 ==      All Targets - Mega Only      ==
 =======================================
 
-- All TB Stack Modules in Release (TB Stack, TB Unit Tests,
-TB Examples) for Arduino ATMega 2560 with Ethernet Shield:
+- All Lite Stack Modules in Release (Lite Stack, Lite Unit Tests, Lite
+  Examples) for Arduino ATMega 2560 with Ethernet Shield:
 
        make -f buildScript.mk arduinomega
 
-- All TB Stack Modules in Debug (TB Stack, TB Unit Tests,
-TB Examples) for Arduino ATMega 2560 with Ethernet Shield:
+- All Lite Stack Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples)
+  for Arduino ATMega 2560 with Ethernet Shield:
 
        make -f buildScript.mk arduinomega_debug
 
-- All TB Stack Modules in Release (TB Stack, TB Unit Tests,
-TB Examples) for Arduino ATMega 2560 with WiFi Shield:
+- All Lite Stack Modules in Release (Lite Stack, Lite Unit Tests, Lite
+  Examples) for Arduino ATMega 2560 with WiFi Shield:
 
        make -f buildScript.mk arduinomega_wifi
 
-- All TB Stack Modules in Debug (TB Stack, TB Unit Tests,
-TB Examples) for Arduino ATMega 2560 with WiFi Shield:
+- All Lite Stack Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples)
+  for Arduino ATMega 2560 with WiFi Shield:
 
        make -f buildScript.mk arduinomega_wifi_debug
 
@@ -191,23 +225,23 @@ TB Examples) for Arduino ATMega 2560 with WiFi Shield:
 ==      All Targets - Due Only      ==
 =======================================
 
-- All TB Stack Modules in Release (TB Stack, TB Unit Tests,
-TB Examples) for Arduino Due with Ethernet Shield:
+- All Lite Stack Modules in Release (Lite Stack, Lite Unit Tests, Lite
+  Examples) for Arduino Due with Ethernet Shield:
 
        make -f buildScript.mk arduinodue_all
 
-- All TB Stack Modules in Debug (TB Stack, TB Unit Tests,
-TB Examples) for Arduino Due with Ethernet Shield:
+- All Lite Stack Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples)
+  Examples) for Arduino Due with Ethernet Shield:
 
        make -f buildScript.mk arduinodue_all_debug
 
-- All TB Stack Modules in Release (TB Stack, TB Unit Tests,
-TB Examples) for Arduino Due with WiFi Shield:
+- All Lite Stack Modules in Release (Lite Stack, Lite Unit Tests, Lite
+  Examples) for Arduino Due with WiFi Shield:
 
        make -f buildScript.mk arduinodue_wifi
 
-- All TB Stack Modules in Debug (TB Stack, TB Unit Tests,
-TB Examples) for Arduino Due with WiFi Shield:
+- All Lite Stack Modules in Debug (Lite Stack, Lite Unit Tests, Lite Examples)
+  for Arduino Due with WiFi Shield:
 
        make -f buildScript.mk arduinodue_wifi_debug
 
index 16d0d62..bb53325 100644 (file)
 # Arduino ATMega 2560:
 #    Framework Version: Arduino 1.0.5
 #    AVR-GCC Version: 4.5.3
+#
+# Arduino Due:
+#    Framework Version: Arduino 1.5.7
+#    AVR-GCC Version: 4.8.3
 
 # Header Description:
 # ====NAME/TITLE - BUILD TYPE - OUT DIRECTORY====
@@ -112,9 +116,9 @@ linux_ub: linux_ub_release
 
 linux_ub_all: linux_ub_release linux_ub_debug
 
-linux_ub_release: linux_tb_stack_release linux_ub_stack_release linux_ub_examples_release
+linux_ub_release: linux_tb_stack_release linux_ub_unittests_release linux_ub_stack_release linux_ub_examples_release
 
-linux_ub_debug: linux_tb_stack_debug linux_ub_stack_debug linux_ub_examples_debug
+linux_ub_debug: linux_tb_stack_debug linux_ub_unittests_debug linux_ub_stack_debug linux_ub_examples_debug
 
 ###############################################################################
 ####      TB Stack - Linux Only                                            ####
@@ -185,7 +189,23 @@ linux_ub_stack_debug: linux_tb_stack_debug
        $(MAKE) -C ./ "buildScript_all" "BUILD=debug"
 
 ###############################################################################
-####      UB Examples - Linux Only                                         ####
+####      UB Unit Tests (& TB Stack as prequisite) - Linux Only            ####
+###############################################################################
+
+linux_ub_unittests: linux_ub_unittests_release
+
+linux_ub_unittests_all: linux_ub_unittests_release linux_ub_unittests_debug
+
+linux_ub_unittests_release: linux_ub_stack_release
+       @echo "=====BUILD UB UNIT TESTS FOR LINUX - RELEASE - <oic-resource>/unittests/release====="
+       $(MAKE) -C unittests/ "BUILD=release"
+
+linux_ub_unittests_debug: linux_ub_stack_debug
+       @echo "=====BUILD UB UNIT TESTS FOR LINUX - DEBUG - <oic-resource>/unittests/debug====="
+       $(MAKE) -C unittests/ "BUILD=debug"
+
+###############################################################################
+####      UB Examples (& UB Stack as prerequisite) - Linux Only            ####
 ###############################################################################
 
 linux_ub_examples: linux_ub_examples_release
@@ -202,10 +222,10 @@ linux_ub_examples_debug: linux_ub_stack_debug
 
 ###############################################################################
 ####      TB Stack, TB Unit Tests, TB Examples, UB Stack, UB Examples,     ####
-####      & OCICUC - Linux Only                                            ####
+####      UB Unit Tests, & OCICUC - Linux Only                             ####
 ###############################################################################
 
-linux_ub_dev: linux_ub_stack_all linux_tb_examples_all
+linux_ub_dev: linux_ub_stack_all linux_ub_unittests_all linux_ub_examples_all linux_tb_examples_all
        @echo "=====BUILD UB OCICUC - <oic-resource>/examples/ocicuc/====="
        $(MAKE) -C examples/ocicuc/
 
@@ -495,5 +515,13 @@ clean:
        $(MAKE) -C csdk/stack/samples/linux/SimpleClientServer "clean"
        $(MAKE) -C csdk/stack/samples/arduino/SimpleClientServer/ocserver "clean"
        $(MAKE) -C . "clean"
+       $(MAKE) -C unittests/ "clean"
        $(MAKE) -C examples/ "clean"
        $(MAKE) -C oc_logger/ "clean"
+
+###############################################################################
+### You must specify arduinomega or arduinodue when using an arduino target.###
+###############################################################################
+arduino:
+       $(error "You must specify "arduinomega" or "arduinodue" when trying to\
+       build arduino targets.")
index 28b4bd4..de6594e 100644 (file)
@@ -1,25 +1,27 @@
-
-tests.cpp contains unitests for C++ APIs.  It uses Google Test for the unit tests.
+tests.cpp contains unittests for C++ APIs. It uses Google Test for the unit
+tests.  Note that the unit tests are only to test the functionality of OCApi.h.
+It is not a system or end-to-end test.
 
 Unit Test Requirements:
 
-1. Install Google Test on a Linux build machine:
+1. Install Google Test 1.7.0 on a Linux build machine to <gtest-1.7.0> from the
+   following address:
+
        http://code.google.com/p/googletest/downloads/list
 
-2. Create a file called "local.properties" in the
-   root/unittests.  local.properties is used
-   by the makefile and specifies the path to the
-   Google Test directory on the build machine.
-   Since local.properties is specific to each build
-   system, do not add local.properties to the code repo.
+2. Create/Append a file named "local.properties" at <oic-resource>/csdk.
+   "local.properties" is used by the build process to specify the path to the
+   Google Test directory.
+
+   local.properties should contain GTEST_DIR, as follows:
 
-   local.properties should contain GTEST_DIR.
-   For example:
+   GTEST_DIR := <gtest-1.7.0>
 
-   GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
+3. To run the unit test, first build the unit tests with the following command
+   from <oic-resource>:
 
-4. To run the unit test, first build the stack.
+   make -f buildScript.mk linux_ub_unittests
 
-5. Run the unit test by
-   root/unittests/release/tests
+4. Run the unit test by issuing the following command from <oic-resource>:
 
+   ./unittests/tests
index f0f22ff..e8283c0 100644 (file)
@@ -24,11 +24,11 @@ BUILD        := release
 PLATFORM := linux
 CXX     := g++
 
-ROOT_DIR       = $(PWD)
+ROOT_DIR       = ./
 
 # You must create the file "local.properties" on your local machine which contains any local paths, etc
 # local.properties should NOT be committed to repo
-include $(ROOT_DIR)/local.properties
+include $(ROOT_DIR)/../csdk/local.properties
 # GTEST_DIR contains the path to Google Test libs and must be defined in local.properties
 #  Example:
 #  GTEST_DIR := /home/johndoe/utils/gtest-1.7.0
@@ -36,10 +36,7 @@ include $(ROOT_DIR)/local.properties
 # NOTE:  to run app, make sure that LD_LIBRARY_PATH env variable
 #        contains $(GTEST_DIR)/lib/.libs
 
-OUT_DIR          := $(PWD)/$(BUILD)
-OBJ_DIR          := $(OUT_DIR)/obj
-
-OUT_DIR          := $(PWD)
+OUT_DIR          := $(BUILD)
 
 INC_DIRS  := -I../include/
 INC_DIRS  += -I../oc_logger/include
@@ -66,16 +63,12 @@ all: prep_dirs tests
 
 prep_dirs:
        -mkdir -p $(OUT_DIR)
-       -mkdir -p $(OBJ_DIR)
 
 tests: tests.cpp
-       $(CXX) $^ $(CPPFLAGS) -o $(OUT_DIR)/$(BUILD)/$@
+       $(CXX) $^ $(CPPFLAGS) -o $(OUT_DIR)/$@
 
 .PHONY: clean
 
-clean: legacy_clean
+clean:
        -rm -rf release
        -rm -rf debug
-
-legacy_clean:
-       rm -f *.o $(PROGRAMS)