Version: v0.0.0-...-ffc66be Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2021 License: BSD-3-Clause Imports: 17 Imported by: 0



Package nearbytestutils provides utility functions for Nearby Share tests.



View Source
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.

View Source
const DownloadPath = "/home/chronos/user/Downloads/"

DownloadPath is the downloads directory on CrOS.

View Source
const SendDir = DownloadPath + "nearby_test_files"

SendDir is the staging directory for test files when sending from CrOS.


This section is empty.


func ChooseSecondaryDUT

func ChooseSecondaryDUT(hostname, secondaryTarget string) (string, error)

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

func ClearCrOSDownloads(ctx context.Context) error

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

func ExtractCrosTestFiles(ctx context.Context, zipPath string) ([]string, error)

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.

func HashFile

func HashFile(ctx context.Context, filePath, fileName string) (string, error)

HashFile returns the hash for a single file.

func HashFiles

func HashFiles(ctx context.Context, filenames []string, fileDir string) ([]string, error)

HashFiles takes in a list of filenames and returns a list of their hashes.

func RandomDeviceName

func RandomDeviceName(basename string) string

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.

func SaveLogs

func SaveLogs(ctx context.Context, reader *syslog.LineReader, path string) error

SaveLogs saves the logs that have appeared since StartLogging was called, and then closes the individual line readers.

func StartLogging

func StartLogging(ctx context.Context, path string) (*syslog.LineReader, error)

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

func UnzipTestFiles(ctx context.Context, zipPath string) (filenames []string, tempDir string, err error)

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.


type TestData

type TestData struct {
	Filename        string
	TransferTimeout time.Duration
	TestTimeout     time.Duration
	MimeType        nearbysnippet.MimeType

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to