clayborg added a comment. In D126464#3545142 <https://reviews.llvm.org/D126464#3545142>, @PRESIDENT810 wrote:
> I have refactored my code so it should looks cleaner now, but I'm not sure > how to add a test. It seems that adding a test for thin archive on macOS > platforms can be not so straightforward. I see that in > lldb/test/API/functionalities/archives/Makefile, the test suite is using > libtool instead of ar to create archives on macOS platforms, and I don't know > whether I can produce a thin archive with that. Also, ld on macOS platforms > seems to be unable to identify thin archives (I'm using ld64.lld when testing > my code locally). > > I would really appreciate it if someone can provide some advice about how to > implement such a test case here, thank you! Does LLVM have the ability to generate a "llvm-ar" tool that can do the packaging? If so, an easy test would be to create a thin archive and then run the following API from within python: static SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path); If you run this API on a thin archive without your modifications, then you will probably get an empty SBModuleSpecList object. So the flow would be: - make sure "llvm-ar" is built if it already isn't with the "check-lldb" target (might need to add it as a depedency - use the build "llvm-ar" to make an archive that points to two .o files that you build from sources - then run some python in your test case like: # Make the Makefile that uses the built "llvm-ar" one two source files that have .o created for them, and then it runs "llvm-ar" and will produce the "thin.a" in the output directory # This line will point to the "thin.a" that was just built archive_path = self.getBuildArtifact("thin.a") # Get the module specs from the thin archive module_specs = lldb.SBModuleSpecList.GetModuleSpecifications(archive_path) num_specs = module_specs.GetSize() self.assertEqual(num_specs, 2) # For extra credit you can verify that you get the right file path from each file spec obj_path_1 = self.getBuildArtifact("foo.o") obj_path_2 = self.getBuildArtifact("bar.o") self.assertEqual(module_specs.GetSpecAtIndex(0).GetObjectName(), obj_path_1) self.assertEqual(module_specs.GetSpecAtIndex(1).GetObjectName(), obj_path_2) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126464/new/ https://reviews.llvm.org/D126464 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits