github.com/nya3jp/tast@v0.0.0-20230601000426-85c8e4d83a9b/src/go.chromium.org/tast/core/internal/dep/software.go (about) 1 // Copyright 2020 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package dep 6 7 import ( 8 "sort" 9 10 "go.chromium.org/tast/core/framework/protocol" 11 ) 12 13 // SoftwareDeps represents dependencies to software features. 14 type SoftwareDeps = []string 15 16 // missingSoftwareDeps returns a sorted list of dependencies from SoftwareDeps 17 // that aren't present on the DUT (per the passed-in features list). 18 // unknown is a sorted list of unknown software features. It is always a subset 19 // of missing. 20 func missingSoftwareDeps(deps SoftwareDeps, features *protocol.SoftwareFeatures) (missing, unknown []string) { 21 DepLoop: 22 for _, d := range deps { 23 if d == "" { 24 continue DepLoop 25 } 26 for _, f := range features.GetAvailable() { 27 if d == f { 28 continue DepLoop 29 } 30 } 31 missing = append(missing, d) 32 for _, f := range features.GetUnavailable() { 33 if d == f { 34 continue DepLoop 35 } 36 } 37 unknown = append(unknown, d) 38 } 39 sort.Strings(missing) 40 sort.Strings(unknown) 41 return missing, unknown 42 }