Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meson: add unit tests #2495

Merged
merged 2 commits into from
Feb 13, 2023
Merged

meson: add unit tests #2495

merged 2 commits into from
Feb 13, 2023

Conversation

neheb
Copy link
Collaborator

@neheb neheb commented Feb 7, 2023

Signed-off-by: Rosen Penev [email protected]

@ghost
Copy link

ghost commented Feb 7, 2023

👇 Click on the image for a new way to code review
  • Make big changes easier — review code in small groups of related files

  • Know where to start — see the whole change at a glance

  • Take a code tour — explore the change with an interactive tour

  • Make comments and review — all fully sync’ed with github

    Try it now!

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map Legend

@codecov
Copy link

codecov bot commented Feb 7, 2023

Codecov Report

Merging #2495 (9e067ab) into main (976dcd8) will not change coverage.
The diff coverage is n/a.

❗ Current head 9e067ab differs from pull request most recent head b490fc7. Consider uploading reports for the commit b490fc7 to get more accurate results

@@           Coverage Diff           @@
##             main    #2495   +/-   ##
=======================================
  Coverage   64.67%   64.67%           
=======================================
  Files         104      104           
  Lines       22256    22256           
  Branches    10863    10863           
=======================================
  Hits        14394    14394           
  Misses       5619     5619           
  Partials     2243     2243           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@neheb
Copy link
Collaborator Author

neheb commented Feb 7, 2023

 exiv2.lib(exiv2-1.dll) : error LNK2005: "public: __cdecl Exiv2::ExifData::~ExifData(void)" (??1ExifData@Exiv2@@QEAA@XZ) already defined in libexiv2int.a(src_tiffimage_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: unsigned __int64 __cdecl Exiv2::DataBuf::size(void)const " (?size@DataBuf@Exiv2@@QEBA_KXZ) already defined in libexiv2int.a(src_tiffimage_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: __cdecl Exiv2::DataBuf::~DataBuf(void)" (??1DataBuf@Exiv2@@QEAA@XZ) already defined in libexiv2int.a(src_tiffimage_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: virtual __cdecl Exiv2::Error::~Error(void)" (??1Error@Exiv2@@UEAA@XZ) already defined in libexiv2int.a(src_tiffimage_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: bool __cdecl Exiv2::DataBuf::empty(void)const " (?empty@DataBuf@Exiv2@@QEBA_NXZ) already defined in libexiv2int.a(src_pngchunk_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: __cdecl Exiv2::DataBuf::DataBuf(void)" (??0DataBuf@Exiv2@@QEAA@XZ) already defined in libexiv2int.a(src_pngchunk_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: struct Exiv2::DataBuf & __cdecl Exiv2::DataBuf::operator=(struct Exiv2::DataBuf &&)" (??4DataBuf@Exiv2@@QEAAAEAU01@$$QEAU01@@Z) already defined in libexiv2int.a(src_pngchunk_int.cpp.obj)
exiv2.lib(exiv2-1.dll) : error LNK2005: "public: class std::_Vector_iterator<class std::_Vector_val<struct std::_Simple_types<unsigned char> > > __cdecl Exiv2::DataBuf::begin(void)" (?begin@DataBuf@Exiv2@@QEAA?AV?$_Vector_iterator@V?$_Vector_val@U?$_Simple_types@E@std@@@std@@@std@@XZ) already defined in libexiv2int.a(src_cr2header_int.cpp.obj)

That is...very interesting

Comment on lines 48 to 51
unit_tests = executable(
test_sources,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing executable name. This executable is therefore unitTests/mainTestRunner.cpp.exe and it doesn't include the main() implementation from there (instead it uses gtest_main?).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

knew there was some reason files() didn't work. Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, in Meson git master the python traceback is fixed with real type checking:

unitTests/meson.build:48:0: ERROR: executable argument 1 was of type "File" but should have been "str"

@neheb
Copy link
Collaborator Author

neheb commented Feb 7, 2023

fascinating. I got it to compile with MinGW but not MSVC.

@neheb
Copy link
Collaborator Author

neheb commented Feb 8, 2023

reading http://google.github.io/googletest/primer.html#writing-the-main-function and seeing unitTests/mainTestRunner.cpp makes me think it's completely unnecessary. Different PR of course.

@piponazo what do you think?

@neheb
Copy link
Collaborator Author

neheb commented Feb 9, 2023

 stderr:
Warning: Unsupported date format
Warning: Unsupported date format
Warning: Unsupported date format
Warning: Unsupported date format
Warning: Unsupported date format
Warning: Unsupported date format
Warning: Unsupported date format
Warning: Unsupported time format
Warning: Unsupported time format
Warning: Unsupported time format
Warning: Unsupported time format
Warning: Unsupported time format
Warning: Unsupported time format
Warning: Unsupported time format
double free or corruption (!prev)

only on linux even though all tests passed. hmmmm.

@neheb
Copy link
Collaborator Author

neheb commented Feb 9, 2023

uhhh fixed by using gtest-main? That can't be right...

@neheb
Copy link
Collaborator Author

neheb commented Feb 10, 2023

issue in Linux is:

double free or corruption (!prev)

Program received signal SIGABRT, Aborted.
0x00007ffff72afe5c in __pthread_kill_implementation () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install expat-2.5.0-1.fc37.x86_64 glibc-2.36-9.fc37.x86_64 gmock-1.12.1-2.fc37.x86_64 gtest-1.12.1-2.fc37.x86_64 inih-56-2.fc37.x86_64 keyutils-libs-1.6.1-5.fc37.x86_64 krb5-libs-1.19.2-13.fc37.x86_64 libbrotli-1.0.9-9.fc37.x86_64 libcom_err-1.46.5-3.fc37.x86_64 libcurl-minimal-7.85.0-5.fc37.x86_64 libgcc-12.2.1-4.fc37.x86_64 libidn2-2.3.4-1.fc37.x86_64 libnghttp2-1.51.0-1.fc37.x86_64 libselinux-3.4-5.fc37.x86_64 libstdc++-12.2.1-4.fc37.x86_64 libunistring-1.0-2.fc37.x86_64 pcre2-10.40-1.fc37.1.x86_64 zlib-1.2.12-5.fc37.x86_64
(gdb) bt
#0  0x00007ffff72afe5c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007ffff725fa76 in raise () from /lib64/libc.so.6
#2  0x00007ffff72497fc in abort () from /lib64/libc.so.6
#3  0x00007ffff72a408e in __libc_message () from /lib64/libc.so.6
#4  0x00007ffff72b9b9c in malloc_printerr () from /lib64/libc.so.6
#5  0x00007ffff72bbccc in _int_free () from /lib64/libc.so.6
#6  0x00007ffff72be363 in free () from /lib64/libc.so.6
#7  0x0000000000643edf in std::__new_allocator<std::__detail::_Hash_node_base*>::deallocate (this=0x7fffffffe177, __p=0x7f7280, __n=541)
    at /usr/include/c++/12/bits/new_allocator.h:158
#8  0x0000000000642dc6 in std::allocator_traits<std::allocator<std::__detail::_Hash_node_base*> >::deallocate (__a=..., __p=0x7f7280, __n=541)
    at /usr/include/c++/12/bits/alloc_traits.h:496
#9  0x000000000064222a in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)>, true> > >::_M_deallocate_buckets (this=0x7a44a0 <Exiv2::Internal::TiffCreator::tiffGroupTable_>, __bkts=0x7f7280, __bkt_count=541)
    at /usr/include/c++/12/bits/hashtable_policy.h:2032
#10 0x0000000000640aec in std::_Hashtable<std::pair<unsigned int, Exiv2::IfdId>, std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)>, std::allocator<std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)> >, std::__detail::_Select1st, std::equal_to<std::pair<unsigned int, Exiv2::IfdId> >, Exiv2::Internal::TiffGroupKey_hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets (
    this=0x7a44a0 <Exiv2::Internal::TiffCreator::tiffGroupTable_>, __bkts=0x7f7280, __bkt_count=541) at /usr/include/c++/12/bits/hashtable.h:452
#11 0x000000000063f0c4 in std::_Hashtable<std::pair<unsigned int, Exiv2::IfdId>, std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)>, std::allocator<std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)> >, std::__detail::_Select1st, std::equal_to<std::pair<unsigned int, Exiv2::IfdId> >, Exiv2::Internal::TiffGroupKey_hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets (
    this=0x7a44a0 <Exiv2::Internal::TiffCreator::tiffGroupTable_>) at /usr/include/c++/12/bits/hashtable.h:457
#12 0x000000000063dbec in std::_Hashtable<std::pair<unsigned int, Exiv2::IfdId>, std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)>, std::allocator<std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)> >, std::__detail::_Select1st, std::equal_to<std::pair<unsigned int, Exiv2::IfdId> >, Exiv2::Internal::TiffGroupKey_hash, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::~_Hashtable (
    this=0x7a44a0 <Exiv2::Internal::TiffCreator::tiffGroupTable_>, __in_chrg=<optimized out>) at /usr/include/c++/12/bits/hashtable.h:1585
#13 0x0000000000645be6 in std::unordered_map<std::pair<unsigned int, Exiv2::IfdId>, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId), Exiv2::Internal::TiffGroupKey_hash, std::equal_to<std::pair<unsigned int, Exiv2::IfdId> >, std::allocator<std::pair<std::pair<unsigned int, Exiv2::IfdId> const, std::unique_ptr<Exiv2::Internal::TiffComponent, std::default_delete<Exiv2::Internal::TiffComponent> > (*)(unsigned short, Exiv2::IfdId)> > >::~unordered_map (this=0x7a44a0 <Exiv2::Internal::TiffCreator::tiffGroupTable_>, __in_chrg=<optimized out>)
    at /usr/include/c++/12/bits/unordered_map.h:102
#14 0x00007ffff7261b97 in __cxa_finalize () from /lib64/libc.so.6
#15 0x00007ffff7ac7ad7 in __do_global_dtors_aux () from /home/mangix/devstuff/exiv2/a/unitTests/../libexiv2.so.1
#16 0x00007fffffffe3f0 in ?? ()
#17 0x00007ffff7fcca9e in _dl_fini () at dl-fini.c:142

why would tiffGroupTable_ be double freed? ping @kevinbackhouse

@neheb
Copy link
Collaborator Author

neheb commented Feb 10, 2023

Fixed by replacing unordered_map with map. But I still get

1/1 Unit Tests FAIL            0.10s   killed by signal 11 SIGSEGV

even though running the tests manually succeeds, No idea what's going on here.

@eli-schwartz any idea what's happening?

Necessary for the Unit Tests.

Signed-off-by: Rosen Penev <[email protected]>
@neheb
Copy link
Collaborator Author

neheb commented Feb 12, 2023

 ld: warning: direct access in function 'Exiv2::Jp2Image::doWriteMetadata(Exiv2::BasicIo&)' from file 'libexiv2.a(src_jp2image.cpp.o)' to global weak symbol 'std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::endl<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)' from file 'exiv2.p/app_actions.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

is a hint to what's wrong.

Signed-off-by: Rosen Penev <[email protected]>
@neheb
Copy link
Collaborator Author

neheb commented Feb 12, 2023

Alright this is as good as it will ever get honestly.

@neheb
Copy link
Collaborator Author

neheb commented Feb 12, 2023

ping @piponazo

@kevinbackhouse
Copy link
Collaborator

tiffGroupTable_

Apologies for the slow reply, I was busy recently. That's very weird: tiffGroupTable_ is a constant global, so I don't understand how that can happen.

const TiffGroupTable TiffCreator::tiffGroupTable_ = {

Maybe we should make it static though? It's only used in tiffimage_int.cpp.

@neheb neheb merged commit 52ab999 into Exiv2:main Feb 13, 2023
@neheb neheb deleted the m2 branch February 13, 2023 17:37
@neheb
Copy link
Collaborator Author

neheb commented Feb 13, 2023

Issue was mismatched visibility settings. Ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants