Fix lib name resolution if extension is substring.

If a library happens to contain the extension as a substring in its
name, libNameFromFilePath will return a truncated library name. Change
this calculation to remove the last instance of the extension substring
instead.

Bug: 147140513
Test: Modified rust tests pass.
Change-Id: I0ed91e5f571ed5c4040ee15956a1598846aee43a
This commit is contained in:
Ivan Lozano
2020-02-06 12:05:10 -05:00
parent 026ffecb9d
commit d648c43fec
2 changed files with 5 additions and 3 deletions

View File

@@ -114,13 +114,13 @@ func testRustError(t *testing.T, pattern string, bp string) {
// Test that we can extract the lib name from a lib path.
func TestLibNameFromFilePath(t *testing.T) {
libBarPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/libbar.so")
libBarPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/libbar.so.so")
libLibPath := android.PathForTesting("out/soong/.intermediates/external/libbar/libbar/linux_glibc_x86_64_shared/liblib.dylib.so")
libBarName := libNameFromFilePath(libBarPath)
libLibName := libNameFromFilePath(libLibPath)
expectedResult := "bar"
expectedResult := "bar.so"
if libBarName != expectedResult {
t.Errorf("libNameFromFilePath returned the wrong name; expected '%#v', got '%#v'", expectedResult, libBarName)
}