[FFmpeg-devel,5/5] fate: Add test for namespace prefixes in libraries

Submitted by Mark Thompson on June 24, 2018, 6:25 p.m.

Details

Message ID 20180624182539.32194-5-sw@jkqxz.net
State New
Headers show

Commit Message

Mark Thompson June 24, 2018, 6:25 p.m.
Ensures that there are no external symbols in the built static libraries
which do not have suitable namespace prefixes.
---
Not sure whether this will actually work on all platforms?  (Only tested with Linux/binutils.)

 tests/Makefile           |  1 +
 tests/fate/namespace.mak | 20 ++++++++++++++++++++
 tests/fate/namespace.sh  | 17 +++++++++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 tests/fate/namespace.mak
 create mode 100755 tests/fate/namespace.sh

Comments

Michael Niedermayer June 25, 2018, 5:41 p.m.
On Sun, Jun 24, 2018 at 07:25:39PM +0100, Mark Thompson wrote:
> Ensures that there are no external symbols in the built static libraries
> which do not have suitable namespace prefixes.
> ---
> Not sure whether this will actually work on all platforms?  (Only tested with Linux/binutils.)

fails on mingw64:
TEST    namespace-avcodec
0000000000000160 T __wrap_avcodec_decode_audio4
0000000000000420 T __wrap_avcodec_decode_subtitle2
00000000000002c0 T __wrap_avcodec_decode_video2
0000000000000580 T __wrap_avcodec_encode_audio2
00000000000006e0 T __wrap_avcodec_encode_subtitle
0000000000000840 T __wrap_avcodec_encode_video2
0000000000000000 T __wrap_avcodec_open2
0000000000000dc0 T __wrap_avcodec_receive_frame
0000000000000b00 T __wrap_avcodec_receive_packet
0000000000000c60 T __wrap_avcodec_send_frame
00000000000009a0 T __wrap_avcodec_send_packet
Test namespace-avcodec failed. Look at tests/data/fate/namespace-avcodec.err for details.
make: *** [fate-namespace-avcodec] Error 1
TEST    namespace-avdevice
00000000000014e0 T dshow_show_filter_properties
00000000000001e0 T dshow_try_setup_crossbar_options
0000000000000020 T libAVEnumMediaTypes_AddRef
00000000000001e0 T libAVEnumMediaTypes_Clone
00000000000004c0 T libAVEnumMediaTypes_Create
0000000000000780 T libAVEnumMediaTypes_Destroy
00000000000000e0 T libAVEnumMediaTypes_Next
0000000000000030 T libAVEnumMediaTypes_QueryInterface
0000000000000190 T libAVEnumMediaTypes_Release
0000000000000010 T libAVEnumMediaTypes_Reset
0000000000000000 T libAVEnumMediaTypes_Skip
0000000000000020 T libAVEnumPins_AddRef
00000000000001a0 T libAVEnumPins_Clone
00000000000003b0 T libAVEnumPins_Create
0000000000000580 T libAVEnumPins_Destroy
00000000000000e0 T libAVEnumPins_Next
0000000000000030 T libAVEnumPins_QueryInterface
0000000000000150 T libAVEnumPins_Release
0000000000000010 T libAVEnumPins_Reset
0000000000000000 T libAVEnumPins_Skip
0000000000000160 T libAVFilter_AddRef
0000000000000350 T libAVFilter_Create
0000000000000630 T libAVFilter_Destroy
0000000000000220 T libAVFilter_EnumPins
0000000000000260 T libAVFilter_FindPin
0000000000000000 T libAVFilter_GetClassID
0000000000000050 T libAVFilter_GetState
00000000000000c0 T libAVFilter_GetSyncSource
00000000000002d0 T libAVFilter_JoinFilterGraph
0000000000000020 T libAVFilter_Pause
0000000000000100 T libAVFilter_QueryFilterInfo
0000000000000170 T libAVFilter_QueryInterface
0000000000000150 T libAVFilter_QueryVendorInfo
0000000000000300 T libAVFilter_Release
0000000000000030 T libAVFilter_Run
0000000000000070 T libAVFilter_SetSyncSource
0000000000000010 T libAVFilter_Stop
0000000000000170 T libAVMemInputPin_AddRef
0000000000000d70 T libAVMemInputPin_Destroy
0000000000000120 T libAVMemInputPin_GetAllocator
0000000000000140 T libAVMemInputPin_GetAllocatorRequirements
0000000000000130 T libAVMemInputPin_NotifyAllocator
0000000000000660 T libAVMemInputPin_QueryInterface
0000000000000360 T libAVMemInputPin_Receive
0000000000000150 T libAVMemInputPin_ReceiveCanBlock
0000000000000750 T libAVMemInputPin_ReceiveMultiple
0000000000000610 T libAVMemInputPin_Release
0000000000000160 T libAVPin_AddRef
00000000000000f0 T libAVPin_BeginFlush
0000000000000000 T libAVPin_Connect
0000000000000060 T libAVPin_ConnectedTo
0000000000000270 T libAVPin_ConnectionMediaType
00000000000009b0 T libAVPin_Create
0000000000000d30 T libAVPin_Destroy
0000000000000010 T libAVPin_Disconnect
0000000000000100 T libAVPin_EndFlush
00000000000000e0 T libAVPin_EndOfStream
0000000000000320 T libAVPin_EnumMediaTypes
0000000000000110 T libAVPin_NewSegment
00000000000000c0 T libAVPin_QueryAccept
00000000000000a0 T libAVPin_QueryDirection
00000000000002f0 T libAVPin_QueryId
0000000000000180 T libAVPin_QueryInterface
00000000000000d0 T libAVPin_QueryInternalConnections
00000000000002a0 T libAVPin_QueryPinInfo
0000000000000520 T libAVPin_ReceiveConnection
00000000000005c0 T libAVPin_Release
Test namespace-avdevice failed. Look at tests/data/fate/namespace-avdevice.err for details.
make: *** [fate-namespace-avdevice] Error 1
TEST    namespace-avfilter
TEST    namespace-avformat
TEST    namespace-avutil
TEST    namespace-postproc
TEST    namespace-swresample
0000000000000000 T __wrap_swr_convert
Test namespace-swresample failed. Look at tests/data/fate/namespace-swresample.err for details.
make: *** [fate-namespace-swresample] Error 1
TEST    namespace-swscale
0000000000000000 T __wrap_sws_scale
Test namespace-swscale failed. Look at tests/data/fate/namespace-swscale.err for details.
make: *** [fate-namespace-swscale] Error 1

[...]
Mark Thompson June 25, 2018, 6:48 p.m.
On 25/06/18 18:41, Michael Niedermayer wrote:
> On Sun, Jun 24, 2018 at 07:25:39PM +0100, Mark Thompson wrote:
>> Ensures that there are no external symbols in the built static libraries
>> which do not have suitable namespace prefixes.
>> ---
>> Not sure whether this will actually work on all platforms?  (Only tested with Linux/binutils.)
> 
> fails on mingw64:
> TEST    namespace-avcodec
> 0000000000000160 T __wrap_avcodec_decode_audio4
> 0000000000000420 T __wrap_avcodec_decode_subtitle2
> 00000000000002c0 T __wrap_avcodec_decode_video2
> 0000000000000580 T __wrap_avcodec_encode_audio2
> 00000000000006e0 T __wrap_avcodec_encode_subtitle
> 0000000000000840 T __wrap_avcodec_encode_video2
> 0000000000000000 T __wrap_avcodec_open2
> 0000000000000dc0 T __wrap_avcodec_receive_frame
> 0000000000000b00 T __wrap_avcodec_receive_packet
> 0000000000000c60 T __wrap_avcodec_send_frame
> 00000000000009a0 T __wrap_avcodec_send_packet

Should these perhaps be renamed to (say) "ff_wrap_" so that they don't use reserved system namespace?

I can just add __wrap to the set of allowed prefixes if people would prefer not to change.

> Test namespace-avcodec failed. Look at tests/data/fate/namespace-avcodec.err for details.
> make: *** [fate-namespace-avcodec] Error 1
> TEST    namespace-avdevice
> 00000000000014e0 T dshow_show_filter_properties
> 00000000000001e0 T dshow_try_setup_crossbar_options

Patch sent to fix these two.

> 0000000000000020 T libAVEnumMediaTypes_AddRef
> 00000000000001e0 T libAVEnumMediaTypes_Clone
> 00000000000004c0 T libAVEnumMediaTypes_Create
> 0000000000000780 T libAVEnumMediaTypes_Destroy
> 00000000000000e0 T libAVEnumMediaTypes_Next
> 0000000000000030 T libAVEnumMediaTypes_QueryInterface
> 0000000000000190 T libAVEnumMediaTypes_Release
> 0000000000000010 T libAVEnumMediaTypes_Reset
> 0000000000000000 T libAVEnumMediaTypes_Skip
> 0000000000000020 T libAVEnumPins_AddRef
> 00000000000001a0 T libAVEnumPins_Clone
> 00000000000003b0 T libAVEnumPins_Create
> 0000000000000580 T libAVEnumPins_Destroy
> 00000000000000e0 T libAVEnumPins_Next
> 0000000000000030 T libAVEnumPins_QueryInterface
> 0000000000000150 T libAVEnumPins_Release
> 0000000000000010 T libAVEnumPins_Reset
> 0000000000000000 T libAVEnumPins_Skip
> 0000000000000160 T libAVFilter_AddRef
> 0000000000000350 T libAVFilter_Create
> 0000000000000630 T libAVFilter_Destroy
> 0000000000000220 T libAVFilter_EnumPins
> 0000000000000260 T libAVFilter_FindPin
> 0000000000000000 T libAVFilter_GetClassID
> 0000000000000050 T libAVFilter_GetState
> 00000000000000c0 T libAVFilter_GetSyncSource
> 00000000000002d0 T libAVFilter_JoinFilterGraph
> 0000000000000020 T libAVFilter_Pause
> 0000000000000100 T libAVFilter_QueryFilterInfo
> 0000000000000170 T libAVFilter_QueryInterface
> 0000000000000150 T libAVFilter_QueryVendorInfo
> 0000000000000300 T libAVFilter_Release
> 0000000000000030 T libAVFilter_Run
> 0000000000000070 T libAVFilter_SetSyncSource
> 0000000000000010 T libAVFilter_Stop
> 0000000000000170 T libAVMemInputPin_AddRef
> 0000000000000d70 T libAVMemInputPin_Destroy
> 0000000000000120 T libAVMemInputPin_GetAllocator
> 0000000000000140 T libAVMemInputPin_GetAllocatorRequirements
> 0000000000000130 T libAVMemInputPin_NotifyAllocator
> 0000000000000660 T libAVMemInputPin_QueryInterface
> 0000000000000360 T libAVMemInputPin_Receive
> 0000000000000150 T libAVMemInputPin_ReceiveCanBlock
> 0000000000000750 T libAVMemInputPin_ReceiveMultiple
> 0000000000000610 T libAVMemInputPin_Release
> 0000000000000160 T libAVPin_AddRef
> 00000000000000f0 T libAVPin_BeginFlush
> 0000000000000000 T libAVPin_Connect
> 0000000000000060 T libAVPin_ConnectedTo
> 0000000000000270 T libAVPin_ConnectionMediaType
> 00000000000009b0 T libAVPin_Create
> 0000000000000d30 T libAVPin_Destroy
> 0000000000000010 T libAVPin_Disconnect
> 0000000000000100 T libAVPin_EndFlush
> 00000000000000e0 T libAVPin_EndOfStream
> 0000000000000320 T libAVPin_EnumMediaTypes
> 0000000000000110 T libAVPin_NewSegment
> 00000000000000c0 T libAVPin_QueryAccept
> 00000000000000a0 T libAVPin_QueryDirection
> 00000000000002f0 T libAVPin_QueryId
> 0000000000000180 T libAVPin_QueryInterface
> 00000000000000d0 T libAVPin_QueryInternalConnections
> 00000000000002a0 T libAVPin_QueryPinInfo
> 0000000000000520 T libAVPin_ReceiveConnection
> 00000000000005c0 T libAVPin_Release

From the vtable setup it looks like they should all be static (the pointers are assigned during setup), but I don't know if they are also needed for some other directshow magic.  Does anyone know if there is some requirement for them to be external symbols?

If they need to be external then I would add the prefix "libAV" to be allowed.

> Test namespace-avdevice failed. Look at tests/data/fate/namespace-avdevice.err for details.
> make: *** [fate-namespace-avdevice] Error 1
> TEST    namespace-avfilter
> TEST    namespace-avformat
> TEST    namespace-avutil
> TEST    namespace-postproc
> TEST    namespace-swresample
> 0000000000000000 T __wrap_swr_convert
> Test namespace-swresample failed. Look at tests/data/fate/namespace-swresample.err for details.
> make: *** [fate-namespace-swresample] Error 1
> TEST    namespace-swscale
> 0000000000000000 T __wrap_sws_scale
> Test namespace-swscale failed. Look at tests/data/fate/namespace-swscale.err for details.
> make: *** [fate-namespace-swscale] Error 1
> 
> [...]

Thanks,

- Mark

Patch hide | download patch | download mbox

diff --git a/tests/Makefile b/tests/Makefile
index e564279b0a..f09c57ac0f 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -154,6 +154,7 @@  include $(SRC_PATH)/tests/fate/mpeg4.mak
 include $(SRC_PATH)/tests/fate/mpegps.mak
 include $(SRC_PATH)/tests/fate/mpegts.mak
 include $(SRC_PATH)/tests/fate/mxf.mak
+include $(SRC_PATH)/tests/fate/namespace.mak
 include $(SRC_PATH)/tests/fate/opus.mak
 include $(SRC_PATH)/tests/fate/pcm.mak
 include $(SRC_PATH)/tests/fate/pixlet.mak
diff --git a/tests/fate/namespace.mak b/tests/fate/namespace.mak
new file mode 100644
index 0000000000..84a1fb17c6
--- /dev/null
+++ b/tests/fate/namespace.mak
@@ -0,0 +1,20 @@ 
+
+define FATE_NAMESPACE
+# (library_name, config_option)
+FATE_NAMESPACE-$(call ALLYES, STATIC $(2)) += fate-namespace-$(1)
+fate-namespace-$(1): lib$(1)/$(LIBPREF)$(1)$(LIBSUF)
+fate-namespace-$(1): CMD = runlocal fate/namespace.sh "$(NM_CMD) lib$(1)/$(LIBPREF)$(1)$(LIBSUF)"
+fate-namespace-$(1): CMP = null
+endef
+
+$(eval $(call FATE_NAMESPACE,avutil,     AVUTIL))
+$(eval $(call FATE_NAMESPACE,avcodec,    AVCODEC))
+$(eval $(call FATE_NAMESPACE,avformat,   AVFORMAT))
+$(eval $(call FATE_NAMESPACE,avfilter,   AVFILTER))
+$(eval $(call FATE_NAMESPACE,avdevice,   AVDEVICE))
+$(eval $(call FATE_NAMESPACE,swscale,    SWSCALE))
+$(eval $(call FATE_NAMESPACE,swresample, SWRESAMPLE))
+$(eval $(call FATE_NAMESPACE,postproc,   POSTPROC))
+
+FATE += $(FATE_NAMESPACE-yes)
+fate-namespace: $(FATE_NAMESPACE-yes)
diff --git a/tests/fate/namespace.sh b/tests/fate/namespace.sh
new file mode 100755
index 0000000000..5d43cc2916
--- /dev/null
+++ b/tests/fate/namespace.sh
@@ -0,0 +1,17 @@ 
+#!/bin/sh
+
+if $1 |
+   grep ' [TDB] ' | # Filter to all global text/data/bss symbols.
+   grep -v ' ff_' | # Internal-only globals.
+   grep -v ' av'  | # libav* external API.
+   grep -v ' sws' | # libswscale external API.
+   grep -v ' swr' | # libswresample external API.
+   grep -v ' \(postproc\|pp\)_' | # libpostproc external API.
+   grep -v ' \(ffio\|ffurl\)_'  | # Special-case internal ffio/ffurl APIs.
+   grep -v ' rgb2rgb_init_x86\| rgb\(12\|15\|16\|24\|32\|48\|64\)to' # Special-case RGB conversion functions in libswscale.
+then
+    # Any output is an error.
+    exit 1
+else
+    exit 0
+fi