summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-06-21 14:49:31 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-06-21 14:49:31 +0000
commita040772150137253969eebfc7a4d65a491b353ce (patch)
tree6a5fca95ce93294ff06b53dbdfd4e3a81548cea3
parent68a0ca2dade5b6707dd7068b3c59f3d1ead041be (diff)
parent069316a93cb305bf016310fa1bcbe6a34e83804c (diff)
downloadbsdiff-android12-mainline-cellbroadcast-release.tar.gz
Change-Id: Ia7087c4be46dafc79895525c3b0bb3f999cd4fe5
-rw-r--r--Android.bp15
-rw-r--r--AndroidTest.xml26
-rw-r--r--METADATA3
l---------NOTICE1
-rw-r--r--TEST_MAPPING7
-rw-r--r--extents_file_unittest.cc3
-rw-r--r--test_utils.cc7
-rw-r--r--utils.cc5
8 files changed, 34 insertions, 33 deletions
diff --git a/Android.bp b/Android.bp
index 9f68463..ee6dc4f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -12,6 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+package {
+ default_applicable_licenses: ["external_bsdiff_license"],
+}
+
+license {
+ name: "external_bsdiff_license",
+ visibility: [":__subpackages__"],
+ license_kinds: ["SPDX-license-identifier-Apache-2.0","SPDX-license-identifier-BSD"],
+ license_text: ["LICENSE"],
+}
+
cc_defaults {
name: "bsdiff_defaults",
host_supported: true,
@@ -40,6 +51,7 @@ cc_library_static {
"//bootable/recovery:__subpackages__",
"//external/puffin:__subpackages__",
"//system/update_engine:__subpackages__",
+ "//system/core/fs_mgr/libsnapshot:__subpackages__",
],
srcs: [
@@ -151,4 +163,7 @@ cc_test {
cflags: ["-DBSDIFF_TARGET_UNITTEST"],
},
},
+ test_options: {
+ unit_test: true,
+ },
}
diff --git a/AndroidTest.xml b/AndroidTest.xml
deleted file mode 100644
index 6394c0e..0000000
--- a/AndroidTest.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<configuration description="Config for bsdiff_unittest">
- <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
- <option name="cleanup" value="true" />
- <option name="push" value="bsdiff_unittest->/data/local/tmp/bsdiff_unittest" />
- </target_preparer>
- <option name="test-suite-tag" value="apct" />
- <test class="com.android.tradefed.testtype.GTest" >
- <option name="native-test-device-path" value="/data/local/tmp" />
- <option name="module-name" value="bsdiff_unittest" />
- </test>
-</configuration>
diff --git a/METADATA b/METADATA
new file mode 100644
index 0000000..d97975c
--- /dev/null
+++ b/METADATA
@@ -0,0 +1,3 @@
+third_party {
+ license_type: NOTICE
+}
diff --git a/NOTICE b/NOTICE
deleted file mode 120000
index 7a694c9..0000000
--- a/NOTICE
+++ /dev/null
@@ -1 +0,0 @@
-LICENSE \ No newline at end of file
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..598f4c9
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,7 @@
+{
+ "presubmit": [
+ {
+ "name": "bsdiff_unittest"
+ }
+ ]
+}
diff --git a/extents_file_unittest.cc b/extents_file_unittest.cc
index 7dc23be..38f288a 100644
--- a/extents_file_unittest.cc
+++ b/extents_file_unittest.cc
@@ -178,8 +178,9 @@ TEST_F(ExtentsFileTest, ReadFailureFails) {
// A second read that fails will succeed if there was partial data read.
EXPECT_CALL(*mock_file_, Read(_, 10, _)).WillOnce(Return(false));
+ char* buf = reinterpret_cast<char*>(0x1234);
size_t bytes_read = 0;
- EXPECT_TRUE(file.Read(nullptr, 100, &bytes_read));
+ EXPECT_TRUE(file.Read(buf, 100, &bytes_read));
EXPECT_EQ(1U, bytes_read);
}
diff --git a/test_utils.cc b/test_utils.cc
index eb079d5..c1350eb 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -53,11 +53,8 @@ namespace test_utils {
void BsdiffTestEnvironment::SetUp() {
#ifdef BSDIFF_TARGET_UNITTEST
-#define BSDIFF_TARGET_TMP_BASE "/data/tmp"
- if (access(BSDIFF_TARGET_TMP_BASE, F_OK) == -1) {
- mkdir(BSDIFF_TARGET_TMP_BASE, S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH);
- }
- setenv("TMPDIR", BSDIFF_TARGET_TMP_BASE, 1);
+#define BSDIFF_TARGET_TMP_BASE "/data/local/tmp"
+ setenv("TMPDIR", BSDIFF_TARGET_TMP_BASE, 1);
#endif // defined (BSDIFF_TARGET_UNITTEST)
}
diff --git a/utils.cc b/utils.cc
index c3e613e..c82eb98 100644
--- a/utils.cc
+++ b/utils.cc
@@ -7,6 +7,11 @@
namespace bsdiff {
int64_t ParseInt64(const uint8_t* buf) {
+ // BSPatch uses a non-standard encoding of integers.
+ // Highest bit of that integer is used as a sign bit, 1 = negative
+ // and 0 = positive.
+ // Therefore, if the highest bit is set, flip it, then do 2's complement
+ // to get the integer in standard form
int64_t result = buf[7] & 0x7F;
for (int i = 6; i >= 0; i--) {
result <<= 8;