Package nearbytestutils provides utility functions for Nearby Share tests.
- func ChooseSecondaryDUT(hostname, secondaryTarget string) (string, error)
- func ClearCrOSDownloads(ctx context.Context) error
- func ExtractAndroidTestFile(ctx context.Context, zipPath string, a *nearbysnippet.AndroidNearbyDevice) (string, error)
- func ExtractCrosTestFiles(ctx context.Context, zipPath string) (string, error)
- func FileHashComparison(ctx context.Context, filenames string, crosFileDir, androidFileDir string, ...) error
- func HashFile(ctx context.Context, filePath, fileName string) (string, error)
- func HashFiles(ctx context.Context, filenames string, fileDir string) (string, error)
- func RandomDeviceName(basename string) string
- func SaveLogs(ctx context.Context, reader *syslog.LineReader, path string) error
- func StartLogging(ctx context.Context, path string) (*syslog.LineReader, error)
- func UnzipTestFiles(ctx context.Context, zipPath string) (filenames string, tempDir string, err error)
- type TestData
const ( HatchHostname = "chromeos15-row6a-rack12-host2a" OctopusHostname = "chromeos15-row6a-rack12-host2b" SarienHostname = "chromeos15-row16-metro1-host1a" CoralHostname = "chromeos15-row16-metro1-host1b" )
Hostnames of the devices in our temporary Nearby Share lab deployment.
const DownloadPath = "/home/chronos/user/Downloads/"
DownloadPath is the downloads directory on CrOS.
SendDir is the staging directory for test files when sending from CrOS.
This section is empty.
func ChooseSecondaryDUT ¶
ChooseSecondaryDUT figures out which DUT is primary and which is secondary in a Nearby Share CB->CB test. TODO(b/175889133) Remove hardcoded hostnames when multi dut skylab support is available.
func ClearCrOSDownloads ¶
ClearCrOSDownloads clears the Downloads folder (where incoming shares are received).
func ExtractAndroidTestFile ¶
func ExtractAndroidTestFile(ctx context.Context, zipPath string, a *nearbysnippet.AndroidNearbyDevice) (string, error)
ExtractAndroidTestFile prepares a test file to send from an Android device.
func ExtractCrosTestFiles ¶
ExtractCrosTestFiles prepares test files to send from a CrOS device. The test files will be staged in SendDir, which is a subdirectory of the current user's download directory. Callers should defer removing the test files to clean up after tests.
func FileHashComparison ¶
func FileHashComparison(ctx context.Context, filenames string, crosFileDir, androidFileDir string, androidDevice *nearbysnippet.AndroidNearbyDevice) error
FileHashComparison compares file hashes on CrOS and Android after a share has been completed.
HashFile returns the hash for a single file.
HashFiles takes in a list of filenames and returns a list of their hashes.
func RandomDeviceName ¶
RandomDeviceName appends a randomly generated integer (up to 6 digits) to the base device name to avoid conflicts when nearby devices in the lab may be running the same test at the same time.
SaveLogs saves the logs that have appeared since StartLogging was called, and then closes the individual line readers.
func StartLogging ¶
StartLogging starts collecting logs from the specified log file, such as /var/log/chrome/chrome or /var/log/messages. Only log lines that appear after StartLogging is called will be collected, so logs for individual tests can be extracted if tests are running consecutively on a shared fixture or precondition. Callers should defer calling Save with the returned *syslog.LineReader to save the logs and free associated resources.
func UnzipTestFiles ¶
UnzipTestFiles extracts test data files to a temporary directory. Returns an array of base filenames and the name of the temporary dir. The extracted files can then be pushed to the Android device or copied to a user-accessible directory on CrOS, depending on which device is the sender. The data files supplied for file transfer tests should be contained in a .zip file regardless of how many files are being transferred.
TestData contains the values for parameterized tests, such as: - File name of the archive containing files to be shared - File transfer timeout (varies depending on file size) - Total test timeout (transfer timeout + time required for sender and receiver to detect each other) - MIME type of shared files (only required when sending from Android)