wifiutil

package
v0.0.0-...-683b059 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: BSD-3-Clause Imports: 30 Imported by: 0

Documentation

Overview

Package wifiutil contains utilities for remote WiFi tests.

Index

Constants

This section is empty.

Variables

Cert1 defines a certificate used for testing.

Functions

func AssertWifiEnabled

func AssertWifiEnabled(ctx context.Context, tf *wificell.TestFixture) (retErr error)

AssertWifiEnabled makes sure that Wifi is enabled on the DUT. This function sets up a WiFi AP and then asks DUT to connect. The DUT will ping the AP to confirm its functionality.

func AssertWifiEnabledOnChannel

func AssertWifiEnabledOnChannel(ctx context.Context, tf *wificell.TestFixture, channel int) (retErr error)

AssertWifiEnabledOnChannel makes sure that Wifi is enabled on the DUT on a specific channel. Other than configuring the AP to operate on a set channel, it is otherwise the same as AssertWifiEnabled.

func Clamp

func Clamp(x, xmin, xmax int) int

Clamp returns x if it's in range of <xmin, xmax>, otherwise one of the limits if it's below or above.

func CollectPcapForAction

func CollectPcapForAction(fullCtx context.Context, rt support.Capture, name string, ch int, freqOps []iw.SetFreqOption, action func(context.Context) error) (string, error)

CollectPcapForAction starts a capture on the specified channel, performs a custom action, and then stops the capture. The path to the pcap file is returned.

func ConfigureAP

func ConfigureAP(ctx context.Context, s *testing.State, apParams []hostapd.Option, routerIdx int,
	secConfFac security.ConfigFactory) (ap *wificell.APIface, freq int, deconfig func(context.Context, *wificell.APIface) error)

ConfigureAP is a helper wrapper on TestFixture.ConfigureAP that additionally handles error, returns deconfig function and provide channel frequency the AP is configured for. Requires s.FixtValue() to return *wificell.TextFixture. Calls s.Fatal in case of any error during setup.

func ConnectAP

func ConnectAP(ctx context.Context, s *testing.State, ap *wificell.APIface, apIdx int) (disconnect func(context.Context))

ConnectAP is a helper wrapper on TestFixture.ConnectWifiAP that additionally handles errors and returns disconnect function. Requires s.FixtValue() to return *wificell.TextFixture. Calls s.Fatal in case of any error during connect.

func ConnectAndCollectPcap

func ConnectAndCollectPcap(ctx context.Context, tf *wificell.TestFixture, apOps []hostapd.Option) (pcapPath string, apConf *hostapd.Config, err error)

ConnectAndCollectPcap sets up a WiFi AP and then asks DUT to connect. The path to the packet file and the config of the AP is returned. Note: This function assumes that TestFixture spawns Capturer for us.

func DUTActive

func DUTActive(ctx context.Context, servoInst *servo.Servo) (bool, error)

DUTActive accesses ex_system_powerstate to tell if the DUT is in active (S0) state.

func DarkResumeSuspend

func DarkResumeSuspend(fullCtx context.Context, d *dut.DUT, servoInst *servo.Servo) (context.Context, func() error, error)

DarkResumeSuspend suspends the DUT with powerd_dbus_suspend with dark resume enabled. On successful call, a shortened context and a cleanup function to wake up the DUT are returned.

func Max

func Max(a, b int) int

Max return the greater value of a, b.

func Min

func Min(a, b int) int

Min return the lesser value of a, b.

func PollBluetoothBootPref

func PollBluetoothBootPref(ctx context.Context, btClient network.BluetoothServiceClient, expectedStatus BtStatus, credKey string) error

PollBluetoothBootPref polls the DUT's saved bluetooth preference until the context deadline is exceeded or until a result is returned. If an unexpected result is seen, the function emits an error.

func PollBluetoothPoweredStatus

func PollBluetoothPoweredStatus(ctx context.Context, btClient network.BluetoothServiceClient, expectedStatus BtStatus) error

PollBluetoothPoweredStatus polls the DUT's bluetooth adapter powered setting until the context deadline is exceeded or until the correct power setting is observed.

func ReserveForWaitServiceIdle

func ReserveForWaitServiceIdle(ctx context.Context) (context.Context, context.CancelFunc)

ReserveForWaitServiceIdle reserve time for WaitServiceIdle call.

func ScanAndCollectPcap

func ScanAndCollectPcap(fullCtx context.Context, tf *wificell.TestFixture, name string, scanCount, ch int) (string, error)

ScanAndCollectPcap requests active scans and collect pcap file on channel ch. Path to the pcap file is returned.

func ServerIP

func ServerIP() string

ServerIP returns server IP used for the test.

func TryConnect

func TryConnect(ctx context.Context, tf *wificell.TestFixture, ops []hostapd.Option) (retPath string, retErr error)

TryConnect asks DUT to connect to an AP with the given ops. Then, it deconfigs the AP and waits the AP disconnection event of the DUT without explicit disconnect call. The object path of connected service is returned. This simulates the behavior that a user connects to a WiFi network and then leaves its range.

func VerifyMACIsChanged

func VerifyMACIsChanged(ctx context.Context, macAddr net.HardwareAddr, pcapPath string, prevMACs []net.HardwareAddr) error

VerifyMACIsChanged checks whether currently used MAC address (macAddr) is different from any previously used addresses (indicated in prevMACs). It also verifies that none of the previously used MAC addresses is used in communication (by parsing captured packets in pcapPath).

func VerifyMACIsKept

func VerifyMACIsKept(ctx context.Context, macAddr net.HardwareAddr, pcapPath string, origMAC net.HardwareAddr) error

VerifyMACIsKept checks whether currently used MAC address (macAddr) is the same as the original one (origMAC) and that this address is used in all communication (by parsing captured packets in pcapPath).

func VerifyMACUsedForScan

func VerifyMACUsedForScan(ctx context.Context, tf *wificell.TestFixture, ap *wificell.APIface,
	name string, randomize bool, macs []net.HardwareAddr) (retErr error)

VerifyMACUsedForScan forces Scan, collects the pcap and checks for MAC address used in Probe Requests. If the randomize is turned on none of the macs should be used, and if it is turned off then all of the Probes should be using MAC from the first element.

func VerifyWakeOnWifiReason

func VerifyWakeOnWifiReason(
	ctx context.Context,
	tf *wificell.TestFixture,
	dut *dut.DUT,
	duration time.Duration,
	reason string,
	triggerFunc func(context.Context) error,
) error

VerifyWakeOnWifiReason puts the DUT into suspend with timeout=duration, calls the triggerFunc to wake the DUT, and checks the LastWakeReason.

func WaitDUTActive

func WaitDUTActive(ctx context.Context, servoInst *servo.Servo, expectActive bool, timeout time.Duration) error

WaitDUTActive uses servo to wait for DUT to reach/leave active (S0) state.

func WaitServiceIdle

func WaitServiceIdle(ctx context.Context, tf *wificell.TestFixture, servicePath string) error

WaitServiceIdle waits for the service in shill on DUT going to idle state for at most waitServiceIdleTime. This is useful for tests to ensure a clean state when starting or to leaving one part of verification. NOTE: If the test is to verify a specific disconnection, spawn watcher with tf.ExpectShillProperty before the trigger might be preferred.

Types

type BtStatus

type BtStatus bool

BtStatus describes the desired Bluetooth state for the boot pref and adapter powered status.

const (
	// BtOff refers to the bluetooth setting being off
	BtOff BtStatus = false
	// BtOn refers to the bluetooth setting being on
	BtOn = true
)

type ContParam

type ContParam struct {
	ApOpts     [2][]hostapd.Option
	SecConfFac security.ConfigFactory
	EnableFT   bool
	Rounds     int
	Param      interface{}
}

ContParam holds all parameters for the continuity test.

type ContTest

type ContTest struct {
	// contains filtered or unexported fields
}

ContTest hods all varibles to be accessible for the whole continuity test.

func ContinuityTestInitialSetup

func ContinuityTestInitialSetup(ctx context.Context, s *testing.State, tf *wificell.TestFixture) (context.Context, *ContTest, func())

ContinuityTestInitialSetup performs the initial setup of the test environment.

func (*ContTest) ContinuityRound

func (ct *ContTest) ContinuityRound(ctx context.Context, s *testing.State, round int)

ContinuityRound runs one round of the test: scans if necessary and attempts roaming.

func (*ContTest) ContinuityTestSetupFinalize

func (ct *ContTest) ContinuityTestSetupFinalize(ctx context.Context, s *testing.State) (context.Context, func())

ContinuityTestSetupFinalize finalizes the setup of the test environment.

func (*ContTest) Router

func (ct *ContTest) Router() router.Standard

Router returns current router object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL