Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Rename selfupdate to testupdate
Browse files Browse the repository at this point in the history
Signed-off-by: Zee314159 <252806294@qq.com>
  • Loading branch information
Zee314159 committed Sep 24, 2019
1 parent d6db790 commit cfa5179
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 33 deletions.
8 changes: 4 additions & 4 deletions scripts/build_ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ mkdir -p "$TEST_INSTALL_DESTDIR"
LDFLAGS="-s" "$GITREPO_ROOT/scripts/test.sh"

# copy provisioning data and scripts
cp -rf "$GITREPO_ROOT/tests/test_data/prov_selfupdate" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/config/selfupdate.toml" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/scripts/selfupdate_server.py" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/test_data/selfupdate_2.0" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/test_data/prov_testupdate" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/config/testupdate.toml" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/scripts/testupdate_server.py" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/tests/test_data/testupdate_2.0" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/uptane_generator/run/create_repo.sh" "$TEST_INSTALL_DESTDIR"
cp -rf "$GITREPO_ROOT/src/uptane_generator/run/serve_repo.py" "$TEST_INSTALL_DESTDIR"

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/libaktualizr/config/config_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ TEST(config, TomlInt) {
*/
TEST(config, TomlPrimarySerial) {
RecordProperty("zephyr_key", "OTA-988");
Config conf("tests/config/selfupdate.toml");
Config conf("tests/config/testupdate.toml");
EXPECT_EQ(conf.provision.primary_ecu_serial, "723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ key_source = "file"

[provision]
primary_ecu_serial = "723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66"
primary_ecu_hardware_id = "selfupdate-device"
primary_ecu_hardware_id = "testupdate-device"

[pacman]
type = "none"
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ class KeyStore:

@staticmethod
def ca():
return path.join(KeyStore.base_dir, 'tests/test_data/prov_selfupdate/ca.pem')
return path.join(KeyStore.base_dir, 'tests/test_data/prov_testupdate/ca.pem')

@staticmethod
def pkey():
return path.join(KeyStore.base_dir, 'tests/test_data/prov_selfupdate/pkey.pem')
return path.join(KeyStore.base_dir, 'tests/test_data/prov_testupdate/pkey.pem')

@staticmethod
def cert():
return path.join(KeyStore.base_dir, 'tests/test_data/prov_selfupdate/client.pem')
return path.join(KeyStore.base_dir, 'tests/test_data/prov_testupdate/client.pem')


class IPSecondary:
Expand Down
33 changes: 9 additions & 24 deletions tests/test_install_aktualizr_and_update.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#! /bin/bash

set -exuo pipefail

SCRIPT_DIR="$(dirname "$0")"
TEST_INSTALL_DESTDIR=$(mktemp -d)/install
./scripts/selfupdate_server.py 0 "$TEST_INSTALL_DESTDIR"&
./scripts/testupdate_server.py 0 "$TEST_INSTALL_DESTDIR"&
PORT=$("$SCRIPT_DIR/find_listening_port.sh" $!)
trap 'kill %1' EXIT

Expand All @@ -14,38 +15,22 @@ done
$1/src/aktualizr_primary/aktualizr --version

$1/src/uptane_generator/uptane-generator generate --path "$TEST_INSTALL_DESTDIR/fake_root"
$1/src/uptane_generator/uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --filename "./tests/test_data/selfupdate_2.0" --hwid selfupdate-device
$1/src/uptane_generator/uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname selfupdate_2.0 --hwid selfupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66
$1/src/uptane_generator/uptane-generator image --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname testupdate_2.0 --filename "./tests/test_data/testupdate_2.0" --hwid testupdate-device
$1/src/uptane_generator/uptane-generator addtarget --path "$TEST_INSTALL_DESTDIR/fake_root" --targetname testupdate_2.0 --hwid testupdate-device --serial 723f79763eda1c753ce565c16862c79acdde32eb922d6662f088083c51ffde66
$1/src/uptane_generator/uptane-generator signtargets --path "$TEST_INSTALL_DESTDIR/fake_root"

TEMP_DIR=$(mktemp -d)
mkdir -m 700 -p "$TEMP_DIR/import"
cp ./tests/test_data/prov_selfupdate/* "$TEMP_DIR/import"
cp ./tests/test_data/prov_testupdate/* "$TEMP_DIR/import"
echo -e "[storage]\\npath = \"$TEMP_DIR\"\\n[import]\\nbase_path = \"$TEMP_DIR/import\"" > "$TEMP_DIR/conf.toml"
echo -e "[tls]\\nserver = \"http://localhost:$PORT\"" >> "$TEMP_DIR/conf.toml"
$1/src/aktualizr_primary/aktualizr -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" once
TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images
filename=$(echo $($1/src/aktualizr_info/aktualizr-info -c ./tests/config/selfupdate.toml -c "$TEMP_DIR/conf.toml" --director-target | jq '(.signed.targets["selfupdate_2.0"].hashes.sha256)') | tr [a-f] [A-F] | tr -d '"')

ls $TEST_INSTALL_IMAGE_DIR/$filename
$1/src/aktualizr_primary/aktualizr -c ./tests/config/testupdate.toml -c "$TEMP_DIR/conf.toml" once

# check the updated file appeared in the installation directory and sha256sum matches expectation
filename=$(echo $($1/src/aktualizr_info/aktualizr-info -c ./tests/config/testupdate.toml -c "$TEMP_DIR/conf.toml" --director-target | jq '(.signed.targets["testupdate_2.0"].hashes.sha256)') | tr [a-f] [A-F] | tr -d '"')
ls $TEMP_DIR/images/$filename
if [ $? -ne 0 ];then
echo "ERROR: $filename does not exist or sha256sum does not match."
exit 1
fi

# check the updated file appeared in the installation directory and sha256sum matches expectation
#TEST_INSTALL_IMAGE_DIR=$TEMP_DIR/images
# if [ ! -d $TEST_INSTALL_IMAGE_DIR ]; then
# echo "$TEST_INSTALL_IMAGE_DIR does not exist"
# exit 1
#else
# cd $TEST_INSTALL_IMAGE_DIR
# for filename in `ls`; do
# checksum=$(echo $(sha256sum $filename) | cut -f 1 -d " " | tr [a-f] [A-F] )
# if [ "$checksum" != "$filename" ]; then
# echo "ERROR: sha256sum does not match."
# exit 1
# fi
# done
#fi

0 comments on commit cfa5179

Please sign in to comment.