From 6496fba11fbfc1d3364f4eb18e8b47d0fdcc52c5 Mon Sep 17 00:00:00 2001
From: "Guo, Yejun" <yejun.guo@intel.com>
Date: Wed, 8 May 2019 16:05:45 +0800
Subject: [PATCH] add a unit test for dnn module

Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
---
 tests/Makefile               |  5 ++++-
 tests/dnn/Makefile           | 11 +++++++++++
 tests/dnn/dnn-compile-test.c | 10 ++++++++++
 tests/fate/dnn.mak           |  8 ++++++++
 4 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 tests/dnn/Makefile
 create mode 100644 tests/dnn/dnn-compile-test.c
 create mode 100644 tests/fate/dnn.mak

diff --git a/tests/Makefile b/tests/Makefile
index 624292d..0ef571b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -10,7 +10,8 @@ FFMPEG=ffmpeg$(PROGSSUF)$(EXESUF)
 $(AREF): CMP=
 
 APITESTSDIR := tests/api
-FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 $(APITESTSDIR)
+DNNTESTSDIR := tests/dnn
+FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 $(APITESTSDIR) $(DNNTESTSDIR)
 OUTDIRS += $(FATE_OUTDIRS)
 
 $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1
@@ -85,6 +86,7 @@ FILTERDEMDECENCMUX = $(call ALLYES, $(1:%=%_FILTER) $(2)_DEMUXER $(3)_DECODER $(
 PARSERDEMDEC       = $(call ALLYES, $(1)_PARSER $(2)_DEMUXER $(3)_DECODER)
 
 include $(SRC_PATH)/$(APITESTSDIR)/Makefile
+include $(SRC_PATH)/$(DNNTESTSDIR)/Makefile
 
 include $(SRC_PATH)/tests/fate/acodec.mak
 include $(SRC_PATH)/tests/fate/vcodec.mak
@@ -118,6 +120,7 @@ include $(SRC_PATH)/tests/fate/cover-art.mak
 include $(SRC_PATH)/tests/fate/dca.mak
 include $(SRC_PATH)/tests/fate/demux.mak
 include $(SRC_PATH)/tests/fate/dfa.mak
+include $(SRC_PATH)/tests/fate/dnn.mak
 include $(SRC_PATH)/tests/fate/dnxhd.mak
 include $(SRC_PATH)/tests/fate/dpcm.mak
 include $(SRC_PATH)/tests/fate/ea.mak
diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
new file mode 100644
index 0000000..12ebd8d
--- /dev/null
+++ b/tests/dnn/Makefile
@@ -0,0 +1,11 @@
+DNNTESTPROGS += dnn-compile
+
+DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
+DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
+-include $(wildcard $(DNNTESTOBJS:.o=.d))
+
+$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
+	$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) $(FF_EXTRALIBS) $(ELIBS)
+
+testclean::
+	$(RM) $(addprefix $(DNNTESTSDIR)/,$(CLEANSUFFIXES) *-test$(EXESUF))
diff --git a/tests/dnn/dnn-compile-test.c b/tests/dnn/dnn-compile-test.c
new file mode 100644
index 0000000..537d287
--- /dev/null
+++ b/tests/dnn/dnn-compile-test.c
@@ -0,0 +1,10 @@
+#include <stdio.h>
+#include "libavfilter/dnn_interface.h"
+
+int main(int argc, char **argv)
+{
+    DNNModule *module = ff_get_dnn_module(DNN_NATIVE);
+    if (!module)
+        return -1;
+    return 0;
+}
\ No newline at end of file
diff --git a/tests/fate/dnn.mak b/tests/fate/dnn.mak
new file mode 100644
index 0000000..4ba24b6
--- /dev/null
+++ b/tests/fate/dnn.mak
@@ -0,0 +1,8 @@
+FATE_DNN += fate-dnn-compile
+fate-dnn-compile: $(DNNTESTSDIR)/dnn-compile-test$(EXESUF)
+fate-dnn-compile: CMD = run $(DNNTESTSDIR)/dnn-compile-test$(EXESUF)
+fate-dnn-compile: CMP = null
+
+FATE-yes += $(FATE_DNN)
+
+fate-dnn: $(FATE_DNN)
\ No newline at end of file
-- 
2.7.4

