[FFmpeg-devel] [PATCH 1/2] tests/dnn: Make DNN tests regular libavfilter tests

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat Dec 18 00:41:42 EET 2021


Andreas Rheinhardt:
> They test libavfilter internal API, so they should be libavfilter
> test programs (which implies: linked statically to libavfilter
> to access internal APIs and linked normally (statically or dynamically
> depending upon the build configuration) against all the other libs).
> 
> Right now, they are always linked statically against all libs,
> which is a significant size waste compared to shared libs as all
> of libavcodec has been pulled in despite not being really used.
> This also leads to linking failures on systems for which av_export_avutil
> is intended: libavcodec does not expect to be linked statically
> against the library providing avpriv_(cga|vga16)_font in this case.
> This is fixed by this commit.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavfilter/Makefile                          |  3 ++
>  libavfilter/tests/.gitignore                  |  8 +++++
>  .../tests/dnn-layer-avgpool.c                 |  0
>  .../tests/dnn-layer-conv2d.c                  |  0
>  .../tests/dnn-layer-dense.c                   |  0
>  .../tests/dnn-layer-depth2space.c             |  0
>  .../tests/dnn-layer-mathbinary.c              |  0
>  .../tests/dnn-layer-mathunary.c               |  0
>  .../tests/dnn-layer-maximum.c                 |  0
>  .../tests/dnn-layer-pad.c                     |  0
>  tests/Makefile                                |  5 ++-
>  tests/dnn/.gitignore                          |  8 -----
>  tests/dnn/Makefile                            | 18 ----------
>  tests/fate/dnn.mak                            | 34 ++++++++++---------
>  14 files changed, 31 insertions(+), 45 deletions(-)
>  rename tests/dnn/dnn-layer-avgpool-test.c => libavfilter/tests/dnn-layer-avgpool.c (100%)
>  rename tests/dnn/dnn-layer-conv2d-test.c => libavfilter/tests/dnn-layer-conv2d.c (100%)
>  rename tests/dnn/dnn-layer-dense-test.c => libavfilter/tests/dnn-layer-dense.c (100%)
>  rename tests/dnn/dnn-layer-depth2space-test.c => libavfilter/tests/dnn-layer-depth2space.c (100%)
>  rename tests/dnn/dnn-layer-mathbinary-test.c => libavfilter/tests/dnn-layer-mathbinary.c (100%)
>  rename tests/dnn/dnn-layer-mathunary-test.c => libavfilter/tests/dnn-layer-mathunary.c (100%)
>  rename tests/dnn/dnn-layer-maximum-test.c => libavfilter/tests/dnn-layer-maximum.c (100%)
>  rename tests/dnn/dnn-layer-pad-test.c => libavfilter/tests/dnn-layer-pad.c (100%)
>  delete mode 100644 tests/dnn/.gitignore
>  delete mode 100644 tests/dnn/Makefile
> 
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index f4f077af46..d39fab2304 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -587,6 +587,9 @@ SKIPHEADERS-$(CONFIG_VULKAN)                 += vulkan.h vulkan_filter.h
>  
>  TOOLS     = graph2dot
>  TESTPROGS = drawutils filtfmts formats integral
> +TESTPROGS-$(CONFIG_DNN) += dnn-layer-avgpool dnn-layer-conv2d dnn-layer-dense  \
> +                           dnn-layer-depth2space dnn-layer-mathbinary          \
> +                           dnn-layer-mathunary dnn-layer-maximum dnn-layer-pad \
>  
>  TOOLS-$(CONFIG_LIBZMQ) += zmqsend
>  
> diff --git a/libavfilter/tests/.gitignore b/libavfilter/tests/.gitignore
> index 65ef86f2e5..db482cd49b 100644
> --- a/libavfilter/tests/.gitignore
> +++ b/libavfilter/tests/.gitignore
> @@ -1,3 +1,11 @@
> +/dnn-layer-conv2d
> +/dnn-layer-depth2space
> +/dnn-layer-maximum
> +/dnn-layer-pad
> +/dnn-layer-mathbinary
> +/dnn-layer-mathunary
> +/dnn-layer-avgpool
> +/dnn-layer-dense
>  /drawutils
>  /filtfmts
>  /formats
> diff --git a/tests/dnn/dnn-layer-avgpool-test.c b/libavfilter/tests/dnn-layer-avgpool.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-avgpool-test.c
> rename to libavfilter/tests/dnn-layer-avgpool.c
> diff --git a/tests/dnn/dnn-layer-conv2d-test.c b/libavfilter/tests/dnn-layer-conv2d.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-conv2d-test.c
> rename to libavfilter/tests/dnn-layer-conv2d.c
> diff --git a/tests/dnn/dnn-layer-dense-test.c b/libavfilter/tests/dnn-layer-dense.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-dense-test.c
> rename to libavfilter/tests/dnn-layer-dense.c
> diff --git a/tests/dnn/dnn-layer-depth2space-test.c b/libavfilter/tests/dnn-layer-depth2space.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-depth2space-test.c
> rename to libavfilter/tests/dnn-layer-depth2space.c
> diff --git a/tests/dnn/dnn-layer-mathbinary-test.c b/libavfilter/tests/dnn-layer-mathbinary.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-mathbinary-test.c
> rename to libavfilter/tests/dnn-layer-mathbinary.c
> diff --git a/tests/dnn/dnn-layer-mathunary-test.c b/libavfilter/tests/dnn-layer-mathunary.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-mathunary-test.c
> rename to libavfilter/tests/dnn-layer-mathunary.c
> diff --git a/tests/dnn/dnn-layer-maximum-test.c b/libavfilter/tests/dnn-layer-maximum.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-maximum-test.c
> rename to libavfilter/tests/dnn-layer-maximum.c
> diff --git a/tests/dnn/dnn-layer-pad-test.c b/libavfilter/tests/dnn-layer-pad.c
> similarity index 100%
> rename from tests/dnn/dnn-layer-pad-test.c
> rename to libavfilter/tests/dnn-layer-pad.c
> diff --git a/tests/Makefile b/tests/Makefile
> index 1e0345b163..1bf9a7a36b 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -1,3 +1,4 @@
> +
>  THREADS = 1
>  VREF = tests/vsynth1/00.pgm
>  AREF = tests/data/asynth1.sw
> @@ -10,8 +11,7 @@ FFMPEG=ffmpeg$(PROGSSUF)$(EXESUF)
>  $(AREF): CMP=
>  
>  APITESTSDIR := tests/api
> -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)
> +FATE_OUTDIRS = tests/data tests/data/fate tests/data/filtergraphs tests/data/lavf tests/data/lavf-fate tests/data/pixfmt tests/vsynth1 $(APITESTSDIR)
>  OUTDIRS += $(FATE_OUTDIRS)
>  
>  $(VREF): tests/videogen$(HOSTEXESUF) | tests/vsynth1
> @@ -96,7 +96,6 @@ CONFIG_LARGE_TESTS:=
>  endif
>  
>  include $(SRC_PATH)/$(APITESTSDIR)/Makefile
> -include $(SRC_PATH)/$(DNNTESTSDIR)/Makefile
>  
>  include $(SRC_PATH)/tests/fate/acodec.mak
>  include $(SRC_PATH)/tests/fate/vcodec.mak
> diff --git a/tests/dnn/.gitignore b/tests/dnn/.gitignore
> deleted file mode 100644
> index 03b04d6653..0000000000
> --- a/tests/dnn/.gitignore
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -/dnn-layer-conv2d-test
> -/dnn-layer-depth2space-test
> -/dnn-layer-maximum-test
> -/dnn-layer-pad-test
> -/dnn-layer-mathbinary-test
> -/dnn-layer-mathunary-test
> -/dnn-layer-avgpool-test
> -/dnn-layer-dense-test
> diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile
> deleted file mode 100644
> index ef827520de..0000000000
> --- a/tests/dnn/Makefile
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -DNNTESTPROGS += dnn-layer-pad
> -DNNTESTPROGS += dnn-layer-conv2d
> -DNNTESTPROGS += dnn-layer-depth2space
> -DNNTESTPROGS += dnn-layer-dense
> -DNNTESTPROGS += dnn-layer-mathbinary
> -DNNTESTPROGS += dnn-layer-maximum
> -DNNTESTPROGS += dnn-layer-mathunary
> -DNNTESTPROGS += dnn-layer-avgpool
> -
> -DNNTESTOBJS  := $(DNNTESTOBJS:%=$(DNNTESTSDIR)%) $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test.o)
> -DNNTESTPROGS := $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
> --include $(wildcard $(DNNTESTOBJS:.o=.d))
> -
> -$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_STATIC_DEP_LIBS)
> -	$(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^) $(FF_STATIC_DEP_LIBS) $(EXTRALIBS-avcodec) $(EXTRALIBS-avfilter) $(EXTRALIBS-avformat) $(EXTRALIBS-avutil) $(EXTRALIBS-swresample) $(EXTRALIBS)
> -
> -testclean::
> -	$(RM) $(addprefix $(DNNTESTSDIR)/,$(CLEANSUFFIXES) *-test$(EXESUF))
> diff --git a/tests/fate/dnn.mak b/tests/fate/dnn.mak
> index ef07ee45f8..a30a2976d9 100644
> --- a/tests/fate/dnn.mak
> +++ b/tests/fate/dnn.mak
> @@ -1,41 +1,43 @@
> +DNNTESTSDIR := libavfilter/tests
> +
>  FATE_DNN += fate-dnn-layer-pad
> -fate-dnn-layer-pad: $(DNNTESTSDIR)/dnn-layer-pad-test$(EXESUF)
> -fate-dnn-layer-pad: CMD = run $(DNNTESTSDIR)/dnn-layer-pad-test$(EXESUF)
> +fate-dnn-layer-pad: $(DNNTESTSDIR)/dnn-layer-pad$(EXESUF)
> +fate-dnn-layer-pad: CMD = run $(DNNTESTSDIR)/dnn-layer-pad$(EXESUF)
>  fate-dnn-layer-pad: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-conv2d
> -fate-dnn-layer-conv2d: $(DNNTESTSDIR)/dnn-layer-conv2d-test$(EXESUF)
> -fate-dnn-layer-conv2d: CMD = run $(DNNTESTSDIR)/dnn-layer-conv2d-test$(EXESUF)
> +fate-dnn-layer-conv2d: $(DNNTESTSDIR)/dnn-layer-conv2d$(EXESUF)
> +fate-dnn-layer-conv2d: CMD = run $(DNNTESTSDIR)/dnn-layer-conv2d$(EXESUF)
>  fate-dnn-layer-conv2d: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-dense
> -fate-dnn-layer-dense: $(DNNTESTSDIR)/dnn-layer-dense-test$(EXESUF)
> -fate-dnn-layer-dense: CMD = run $(DNNTESTSDIR)/dnn-layer-dense-test$(EXESUF)
> +fate-dnn-layer-dense: $(DNNTESTSDIR)/dnn-layer-dense$(EXESUF)
> +fate-dnn-layer-dense: CMD = run $(DNNTESTSDIR)/dnn-layer-dense$(EXESUF)
>  fate-dnn-layer-dense: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-depth2space
> -fate-dnn-layer-depth2space: $(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
> -fate-dnn-layer-depth2space: CMD = run $(DNNTESTSDIR)/dnn-layer-depth2space-test$(EXESUF)
> +fate-dnn-layer-depth2space: $(DNNTESTSDIR)/dnn-layer-depth2space$(EXESUF)
> +fate-dnn-layer-depth2space: CMD = run $(DNNTESTSDIR)/dnn-layer-depth2space$(EXESUF)
>  fate-dnn-layer-depth2space: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-mathbinary
> -fate-dnn-layer-mathbinary: $(DNNTESTSDIR)/dnn-layer-mathbinary-test$(EXESUF)
> -fate-dnn-layer-mathbinary: CMD = run $(DNNTESTSDIR)/dnn-layer-mathbinary-test$(EXESUF)
> +fate-dnn-layer-mathbinary: $(DNNTESTSDIR)/dnn-layer-mathbinary$(EXESUF)
> +fate-dnn-layer-mathbinary: CMD = run $(DNNTESTSDIR)/dnn-layer-mathbinary$(EXESUF)
>  fate-dnn-layer-mathbinary: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-maximum
> -fate-dnn-layer-maximum: $(DNNTESTSDIR)/dnn-layer-maximum-test$(EXESUF)
> -fate-dnn-layer-maximum: CMD = run $(DNNTESTSDIR)/dnn-layer-maximum-test$(EXESUF)
> +fate-dnn-layer-maximum: $(DNNTESTSDIR)/dnn-layer-maximum$(EXESUF)
> +fate-dnn-layer-maximum: CMD = run $(DNNTESTSDIR)/dnn-layer-maximum$(EXESUF)
>  fate-dnn-layer-maximum: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-mathunary
> -fate-dnn-layer-mathunary: $(DNNTESTSDIR)/dnn-layer-mathunary-test$(EXESUF)
> -fate-dnn-layer-mathunary: CMD = run $(DNNTESTSDIR)/dnn-layer-mathunary-test$(EXESUF)
> +fate-dnn-layer-mathunary: $(DNNTESTSDIR)/dnn-layer-mathunary$(EXESUF)
> +fate-dnn-layer-mathunary: CMD = run $(DNNTESTSDIR)/dnn-layer-mathunary$(EXESUF)
>  fate-dnn-layer-mathunary: CMP = null
>  
>  FATE_DNN += fate-dnn-layer-avgpool
> -fate-dnn-layer-avgpool: $(DNNTESTSDIR)/dnn-layer-avgpool-test$(EXESUF)
> -fate-dnn-layer-avgpool: CMD = run $(DNNTESTSDIR)/dnn-layer-avgpool-test$(EXESUF)
> +fate-dnn-layer-avgpool: $(DNNTESTSDIR)/dnn-layer-avgpool$(EXESUF)
> +fate-dnn-layer-avgpool: CMD = run $(DNNTESTSDIR)/dnn-layer-avgpool$(EXESUF)
>  fate-dnn-layer-avgpool: CMP = null
>  
>  FATE-$(CONFIG_DNN) += $(FATE_DNN)
> 

Will apply this tomorrow unless there are objections.

- Andreas


More information about the ffmpeg-devel mailing list