Skip to content

Commit

Permalink
ci: add gpu and acceleration options to emulator
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon committed Sep 27, 2024
1 parent 898ab93 commit b18e6ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci_emulator_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ jobs:
v retry -- sudo apt update
v retry -- sudo apt install --quiet -y qemu-kvm
sudo chown $USER /dev/kvm
#sudo chgrp kvm /dev/kvm
#sudo chmod g+rw /dev/kvm
- name: Install SDK dependencies
run: |
Expand Down
28 changes: 19 additions & 9 deletions android/emulator/emulator.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,17 @@ pub:
@[params]
pub struct Options {
pub:
verbosity int
wipe_data bool = true
avd string
await_boot bool = true // will wait for the device to boot
visible bool // show emulator window on desktop
metrics bool // send metrics to Google... default NO
snapshot SnapshotOptions
boot_anim bool
camera CameraOptions
verbosity int
wipe_data bool = true
avd string
await_boot bool = true // will wait for the device to boot
visible bool // show emulator window on desktop
metrics bool // send metrics to Google... default NO
snapshot SnapshotOptions
boot_anim bool
camera CameraOptions
gpu string
acceleration string
}

// verbose prints `msg` to STDOUT if `Options.verbosity` level is >= `verbosity_level`.
Expand Down Expand Up @@ -207,6 +209,14 @@ fn (mut e Emulator) run_process(options Options) {
if !e.options.boot_anim {
emulator_args << '-no-boot-anim'
}
if e.options.gpu != '' {
emulator_args << '-gpu'
emulator_args << e.options.gpu
}
if e.options.acceleration != '' {
emulator_args << '-accel'
emulator_args << e.options.acceleration
}
emulator_args << '-camera-front'
emulator_args << e.options.camera.front
emulator_args << '-camera-back'
Expand Down
27 changes: 14 additions & 13 deletions tests/at-runtime/emulator/emulator_test.vv
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ const env_is_managable = env.managable()
fn test_run_on_emulator() {
ensure_env()

mut emu := emulator.make()!
emu.start(
verbosity: 3
await_boot: true
// visible: true // uncomment to show window on desktop
avd: vab_test_avd
)!
mut emu := emulator.make()!
emu.start(
verbosity: 3
await_boot: true
// visible: true // uncomment to show window on desktop
avd: vab_test_avd
// acceleration: 'off'
)!
// start tests ...
// for _ in 0 .. 20 {
// if recv.try_pop(mut signal) == .success {
Expand All @@ -37,17 +38,17 @@ fn test_run_on_emulator() {
//
// }

vab, test_dir := setup(@FN)
vab, test_dir := setup(@FN)

vab_cmd := [vab, '--device',emu.name,'run', v_example('2048'), '-o', test_dir]
vab_cmd := [vab, '--device', emu.name, 'run', v_example('2048'), '-o', test_dir]
res := run(vab_cmd)
if res.exit_code != 0 {
println('error: ${res.output}')
}
if res.exit_code != 0 {
println('error: ${res.output}')
}

time.sleep(10000 * time.millisecond)

emu.stop()
emu.stop()
}

fn ensure_env() {
Expand Down

0 comments on commit b18e6ca

Please sign in to comment.