| #!/bin/bash |
| # Copyright 2023 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| ### Test the helper functions defined in //tools/devshell/lib/disktools.sh |
| |
| BT_FILE_DEPS=( |
| "tools/devshell/lib/disktools.sh" |
| "tools/devshell/lib/generate-ssh-config.sh" |
| ) |
| |
| BT_SET_UP() { |
| source "${BT_TEMP_DIR}/tools/devshell/lib/disktools.sh" |
| } |
| |
| TEST_fx_extend() { |
| tmpfile=$(mktemp "${BT_TEMP_DIR}/temp.XXXXXX") |
| echo "0123456789" > "${tmpfile}" |
| |
| fx-extend "${tmpfile}" 1 |
| BT_ASSERT_EQ "$(wc -c < ${tmpfile} | awk '{print $1}')" "11" |
| |
| fx-extend "${tmpfile}" 12 |
| BT_ASSERT_EQ "$(wc -c < ${tmpfile} | awk '{print $1}')" "12" |
| |
| fx-extend "${tmpfile}" 1K |
| BT_ASSERT_EQ "$(wc -c < ${tmpfile} | awk '{print $1}')" "1024" |
| |
| fx-extend "${tmpfile}" 1M |
| BT_ASSERT_EQ "$(wc -c < ${tmpfile} | awk '{print $1}')" "1048576" |
| |
| fx-extend "${tmpfile}" 10 |
| BT_ASSERT_EQ "$(wc -c < ${tmpfile} | awk '{print $1}')" "1048576" |
| } |
| |
| BT_RUN_TESTS "$@" |