Mark ab/6881855 as merged

Bug: 172690556
Change-Id: I47bc947ec1db1e6362f15db2354d3edbb5de6897
diff --git a/.gitignore b/.gitignore
index 54627e6..ccddf2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,6 +14,9 @@
 *.la
 *.lo
 
+# gcc dependency files
+*.d
+
 # Shared objects (inc. Windows DLLs)
 *.dll
 *.so
@@ -74,3 +77,4 @@
 *.VC.VC.opendb
 *.iobj
 *.ipdb
+decoder/tests/results*
\ No newline at end of file
diff --git a/METADATA b/METADATA
index 825e678..719dd49 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@
     type: GIT
     value: "https://github.com/Linaro/OpenCSD.git"
   }
-  version: "v0.14.3"
+  version: "v0.14.4"
   license_type: RESTRICTED
   last_upgrade_date {
     year: 2020
-    month: 8
-    day: 28
+    month: 11
+    day: 18
   }
 }
diff --git a/README.md b/README.md
index 2a77099..4cdfb37 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@
 CoreSight Trace Component Support.
 ----------------------------------
 
-_Current Version 0.14.3_
+_Current Version 0.14.4_
 
 ### Current support:
 
@@ -216,6 +216,13 @@
     - __Update__: Add section to autofdo document.
     - __Bugfix__: STM: fix bug that was missing ASYNC packets. (github issue #27, reported by subhasish Karmakar)
 
+- _Version 0.14.4_:
+    - __Update__: makefile: Add DESTDIR to install targets. (github issue #30)
+    - __Update__: tests: add script to run single test only.
+    - __Update__: docs: update to location of ARM coresight driver backports directory.
+    - __Bugfix__: ETMv3: Fix missing comma in string list. (github issue #31)
+    - __Bugfix__: makefile: tests: Fix build race problem (github issue #32)
+    - __Bugfix__: tests: fix ignore tpiu command line options (github issue #28)
 
 Licence Information
 ===================
diff --git a/decoder/build/linux/makefile b/decoder/build/linux/makefile
index d4165ce..bf90758 100644
--- a/decoder/build/linux/makefile
+++ b/decoder/build/linux/makefile
@@ -65,9 +65,9 @@
 # installation directory
 PREFIX ?=/usr
 LIB_PATH ?= lib
-INSTALL_LIB_DIR=$(PREFIX)/$(LIB_PATH)
-INSTALL_BIN_DIR=$(PREFIX)/bin
-export INSTALL_INCLUDE_DIR=$(PREFIX)/include/
+INSTALL_LIB_DIR=$(DESTDIR)$(PREFIX)/$(LIB_PATH)
+INSTALL_BIN_DIR=$(DESTDIR)$(PREFIX)/bin
+export INSTALL_INCLUDE_DIR=$(DESTDIR)$(PREFIX)/include/
 
 # compile flags
 CFLAGS += $(CPPFLAGS) -c -Wall -DLINUX -Wno-switch -Wlogical-op -fPIC
diff --git a/decoder/docs/doxygen_config.dox b/decoder/docs/doxygen_config.dox
index 15cf781..b2a3a57 100644
--- a/decoder/docs/doxygen_config.dox
+++ b/decoder/docs/doxygen_config.dox
@@ -38,7 +38,7 @@
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = 0.14.3
+PROJECT_NUMBER         = 0.14.4
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a
diff --git a/decoder/include/opencsd/ocsd_if_version.h b/decoder/include/opencsd/ocsd_if_version.h
index 58eb4b5..e0461db 100644
--- a/decoder/include/opencsd/ocsd_if_version.h
+++ b/decoder/include/opencsd/ocsd_if_version.h
@@ -44,7 +44,7 @@
 @{*/
 #define OCSD_VER_MAJOR 0x0 /**< Library Major Version */
 #define OCSD_VER_MINOR 0xE /**< Library Minor Version */
-#define OCSD_VER_PATCH 0x3 /**< Library Patch Version */
+#define OCSD_VER_PATCH 0x4 /**< Library Patch Version */
 
 /** Library version number - MMMMnnpp format.
     MMMM = major version, 
@@ -53,7 +53,7 @@
 */
 #define OCSD_VER_NUM ((OCSD_VER_MAJOR << 16) | (OCSD_VER_MINOR << 8) | OCSD_VER_PATCH) 
 
-#define OCSD_VER_STRING "0.14.3"    /**< Library Version string */
+#define OCSD_VER_STRING "0.14.4"    /**< Library Version string */
 #define OCSD_LIB_NAME "OpenCSD Library"  /**< Library name string */
 #define OCSD_LIB_SHORT_NAME "OCSD"    /**< Library Short name string */
 /** @}*/
diff --git a/decoder/source/etmv3/trc_pkt_elem_etmv3.cpp b/decoder/source/etmv3/trc_pkt_elem_etmv3.cpp
index f1e411f..74034c3 100644
--- a/decoder/source/etmv3/trc_pkt_elem_etmv3.cpp
+++ b/decoder/source/etmv3/trc_pkt_elem_etmv3.cpp
@@ -659,7 +659,7 @@
         "IRQ4", "IRQ5", "IRQ6", "IRQ7",
         "IRQ0","usage Fault","NMI","SVC",
         "DebugMonitor", "Mem Manage","PendSV","SysTick",
-        "Reserved","PE Reset","Reserved","HardFault"
+        "Reserved","PE Reset","Reserved","HardFault",
         "Reserved","BusFault","Reserved","Reserved"
     };
 
diff --git a/decoder/tests/auto-fdo/autofdo.md b/decoder/tests/auto-fdo/autofdo.md
index b28b645..5d55cd0 100644
--- a/decoder/tests/auto-fdo/autofdo.md
+++ b/decoder/tests/auto-fdo/autofdo.md
@@ -87,12 +87,12 @@
 on these targets, Arm have provided backports of the latest CoreSight
 drivers and ETM strobing patch at:
 
-  <http://linux-arm.org/git?p=linux-coresight-backports.git>
+  <https://gitlab.arm.com/linux-arm/linux-coresight-backports>
 
 This repository can be cloned with:
 
 ```
-git clone git://linux-arm.org/linux-coresight-backports.git
+git clone https://git.gitlab.arm.com/linux-arm/linux-coresight-backports.git
 ```
 
 You can include these backports in your kernel by either merging the
diff --git a/decoder/tests/build/linux/c_api_pkt_print_test/makefile b/decoder/tests/build/linux/c_api_pkt_print_test/makefile
index b0b5604..f1108e4 100644
--- a/decoder/tests/build/linux/c_api_pkt_print_test/makefile
+++ b/decoder/tests/build/linux/c_api_pkt_print_test/makefile
@@ -51,12 +51,12 @@
 LIBS		=	-L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME) -l$(LIB_CAPI_NAME) \
 				-L$(LIB_TEST_TARGET_DIR) -l_echo_test_dcd
 
-all:  build_dir copy_libs
+all: copy_libs
 
 test_app: 	$(BIN_TEST_TARGET_DIR)/$(PROG)
 
 
- $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS)
+ $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS) | build_dir
 			mkdir -p  $(BIN_TEST_TARGET_DIR)
 			$(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
 			cp $(LIB_TARGET_DIR)/*.so .
@@ -77,7 +77,7 @@
 -include $(DEPS)
 
 ## object compile
-$(BUILD_DIR)/%.o : %.c
+$(BUILD_DIR)/%.o : %.c | build_dir
 			$(CC) $(CFLAGS) $(CC_INCLUDES) -MMD $< -o $@ 
 
 #### clean
diff --git a/decoder/tests/build/linux/echo_test_dcd_lib/makefile b/decoder/tests/build/linux/echo_test_dcd_lib/makefile
index 31ca38f..8c255a8 100644
--- a/decoder/tests/build/linux/echo_test_dcd_lib/makefile
+++ b/decoder/tests/build/linux/echo_test_dcd_lib/makefile
@@ -48,9 +48,9 @@
 OBJECTS		=	$(BUILD_DIR)/ext_dcd_echo_test.o \
 				$(BUILD_DIR)/ext_dcd_echo_test_fact.o
 
-all:  build_dir $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+all: $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
 
-$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS)
+$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | build_dir
 	mkdir -p $(LIB_TEST_TARGET_DIR)
 	$(LIB) $(ARFLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
 
@@ -64,7 +64,7 @@
 -include $(DEPS)
 
 ## object compile
-$(BUILD_DIR)/%.o : %.c
+$(BUILD_DIR)/%.o : %.c | build_dir
 			$(CC) $(CFLAGS) $(CC_INCLUDES) -MMD $< -o $@ 
 
 #### clean
diff --git a/decoder/tests/build/linux/mem_buffer_eg/makefile b/decoder/tests/build/linux/mem_buffer_eg/makefile
index 850ed49..7939521 100644
--- a/decoder/tests/build/linux/mem_buffer_eg/makefile
+++ b/decoder/tests/build/linux/mem_buffer_eg/makefile
@@ -51,12 +51,12 @@
 LIBS		=	-L$(LIB_TEST_TARGET_DIR) -lsnapshot_parser \
 				-L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
 
-all:  build_dir copy_libs
+all: copy_libs
 
 test_app: $(BIN_TEST_TARGET_DIR)/$(PROG)
 
 
- $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS)
+ $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS) | build_dir
 			mkdir -p  $(BIN_TEST_TARGET_DIR)
 			$(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
 
@@ -76,7 +76,7 @@
 -include $(DEPS)
 
 ## object compile
-$(BUILD_DIR)/%.o : %.cpp
+$(BUILD_DIR)/%.o : %.cpp | build_dir
 			$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
 
 #### clean
diff --git a/decoder/tests/build/linux/snapshot_parser_lib/makefile b/decoder/tests/build/linux/snapshot_parser_lib/makefile
index 295bab6..ae566eb 100644
--- a/decoder/tests/build/linux/snapshot_parser_lib/makefile
+++ b/decoder/tests/build/linux/snapshot_parser_lib/makefile
@@ -63,9 +63,9 @@
 		$(BUILD_DIR)/snapshot_reader.o \
 		$(BUILD_DIR)/ss_to_dcdtree.o
 
-all: build_dir $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
+all: $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a
 
-$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS)
+$(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a: $(OBJECTS) | build_dir
 	mkdir -p $(LIB_TEST_TARGET_DIR)
 	$(LIB) $(ARFLAGS) $(LIB_TEST_TARGET_DIR)/$(LIB_NAME).a $(OBJECTS)
 
@@ -80,7 +80,7 @@
 -include $(DEPS)
 
 ## object compile
-$(BUILD_DIR)/%.o : %.cpp
+$(BUILD_DIR)/%.o : %.cpp | build_dir
 	$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
 
 ### clean
diff --git a/decoder/tests/build/linux/trc_pkt_lister/makefile b/decoder/tests/build/linux/trc_pkt_lister/makefile
index 54ce27d..6327d3e 100644
--- a/decoder/tests/build/linux/trc_pkt_lister/makefile
+++ b/decoder/tests/build/linux/trc_pkt_lister/makefile
@@ -36,6 +36,7 @@
 LINKER := $(MASTER_LINKER)	
 
 PROG = trc_pkt_lister
+PROG_S = trc_pkt_lister_s
 
 BUILD_DIR=./$(PLAT_DIR)
 
@@ -51,20 +52,26 @@
 LIBS		=	-L$(LIB_TEST_TARGET_DIR) -lsnapshot_parser \
 				-L$(LIB_TARGET_DIR) -l$(LIB_BASE_NAME)
 
-all:  build_dir copy_libs
+all: copy_libs
 
 test_app: $(BIN_TEST_TARGET_DIR)/$(PROG)
 
 
- $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS)
+ $(BIN_TEST_TARGET_DIR)/$(PROG): $(OBJECTS) | build_dir
 			mkdir -p  $(BIN_TEST_TARGET_DIR)
 			$(LINKER) $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG)
 
+$(BIN_TEST_TARGET_DIR)/$(PROG_S): $(OBJECTS) | build_dir
+			mkdir -p  $(BIN_TEST_TARGET_DIR)
+			$(LINKER) -static $(LDFLAGS) $(OBJECTS) -Wl,--start-group $(LIBS) -Wl,--end-group -o $(BIN_TEST_TARGET_DIR)/$(PROG_S)
+
+
+
 build_dir:
 	mkdir -p $(BUILD_DIR)
 
 .PHONY: copy_libs
-copy_libs: $(BIN_TEST_TARGET_DIR)/$(PROG)
+copy_libs: $(BIN_TEST_TARGET_DIR)/$(PROG) $(BIN_TEST_TARGET_DIR)/$(PROG_S) 
 	cp $(LIB_TARGET_DIR)/*.so* $(BIN_TEST_TARGET_DIR)/.
 
 
@@ -76,7 +83,7 @@
 -include $(DEPS)
 
 ## object compile
-$(BUILD_DIR)/%.o : %.cpp
+$(BUILD_DIR)/%.o : %.cpp | build_dir
 			$(CXX) $(CXXFLAGS) $(CXX_INCLUDES) -MMD $< -o $@
 
 #### clean
diff --git a/decoder/tests/run_pkt_decode_single.bash b/decoder/tests/run_pkt_decode_single.bash
new file mode 100755
index 0000000..b4ca58f
--- /dev/null
+++ b/decoder/tests/run_pkt_decode_single.bash
@@ -0,0 +1,76 @@
+#!/bin/bash
+#################################################################################
+# Copyright 2018 ARM. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without modification, 
+# are permitted provided that the following conditions are met:
+# 
+# 1. Redistributions of source code must retain the above copyright notice, 
+# this list of conditions and the following disclaimer.
+# 
+# 2. Redistributions in binary form must reproduce the above copyright notice, 
+# this list of conditions and the following disclaimer in the documentation 
+# and/or other materials provided with the distribution. 
+# 
+# 3. Neither the name of the copyright holder nor the names of its contributors 
+# may be used to endorse or promote products derived from this software without 
+# specific prior written permission. 
+# 
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND 
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
+# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
+# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+# 
+#################################################################################
+# OpenCSD library: run single test
+#
+#
+#################################################################################
+# Usage options:-
+# * default: run test on binary + libs in ./bin/linux64/rel
+# run_pkt_decode_tests.bash <test>
+#
+# * use installed opencsd libraries & program
+# run_pkt_decode_tests.bash use-installed <test>
+#
+#
+
+OUT_DIR=./results
+SNAPSHOT_DIR=./snapshots
+BIN_DIR=./bin/linux64/rel/
+
+TEST="a57_single_step"
+
+mkdir -p ${OUT_DIR}
+
+if [ "$1" == "use-installed" ]; then
+    BIN_DIR=""
+    shift
+fi
+
+if [ "$1" != "" ]; then
+    TEST=$1
+fi
+
+echo "Running trc_pkt_lister on single snapshot ${TEST}"
+
+
+if [ "${BIN_DIR}" != "" ]; then
+    echo "Tests using BIN_DIR = ${BIN_DIR}"
+    export LD_LIBRARY_PATH=${BIN_DIR}.
+    echo "LD_LIBRARY_PATH set to ${BIN_DIR}"
+else
+    echo "Tests using installed binaries"
+fi
+
+# === test the decode set ===
+${BIN_DIR}trc_pkt_lister -ss_dir "${SNAPSHOT_DIR}/${TEST}" -decode -logfilename "${OUT_DIR}/${TEST}.ppl"
+echo "Done : Return $?"
+
+
diff --git a/decoder/tests/source/trc_pkt_lister.cpp b/decoder/tests/source/trc_pkt_lister.cpp
index 50260a5..d3f4588 100644
--- a/decoder/tests/source/trc_pkt_lister.cpp
+++ b/decoder/tests/source/trc_pkt_lister.cpp
@@ -185,9 +185,9 @@
     oss << "\nDecode:\n\n";
     oss << "-id <n>             Set an ID to list (may be used multiple times) - default if no id set is for all IDs to be printed\n";
     oss << "-src_name <name>    List packets from a given snapshot source name (defaults to first source found)\n";
-    oss << "-dstream_format     Input is DSTREAM framed.";
-    oss << "-tpiu               Input from TPIU - sync by FSYNC.";
-    oss << "-tpiu_hsync         Input from TPIU - sync by FSYNC and HSYNC.";
+    oss << "-dstream_format     Input is DSTREAM framed.\n";
+    oss << "-tpiu               Input from TPIU - sync by FSYNC.\n";
+    oss << "-tpiu_hsync         Input from TPIU - sync by FSYNC and HSYNC.\n";
     oss << "-decode             Full decode of the packets from the trace snapshot (default is to list undecoded packets only\n";
     oss << "-decode_only        Does not list the undecoded packets, just the trace decode.\n";
     oss << "-o_raw_packed       Output raw packed trace frames\n";
@@ -518,8 +518,9 @@
         if (!configFlags)
         {
             configFlags = OCSD_DFRMTR_FRAME_MEM_ALIGN;
-            pDeformatter->Configure(configFlags);
         }
+        pDeformatter->Configure(configFlags);
+
         if (outRawPacked || outRawUnpacked)
         {
             if (outRawPacked) configFlags |= OCSD_DFRMTR_PACKED_RAW_OUT;