How to use boot method of main Package

Best Syzkaller code snippet using main.boot

boot.go

Source:boot.go Github

copy

Full Screen

...13// 14// You should have received a copy of the GNU Lesser General Public License 15// along with the MATRIX library. If not, see <http://www.gnu.org/licenses/>. 16// Boot_Find project Boot_Find.go17package boot18import (19 "encoding/json"20 "fmt"21 "net"22 "strings"23 "time"24 "github.com/ethereum/go-ethereum/core"25 "github.com/ethereum/go-ethereum/eth"26 "github.com/ethereum/go-ethereum/log"27 "github.com/ethereum/go-ethereum/election"28 "github.com/ethereum/go-ethereum/p2p"29 "github.com/ethereum/go-ethereum/params"30 "github.com/ethereum/go-ethereum/scheduler"31)32var (33 Public_Seq uint6434 Need_Ack []uint6435 go_bootss bootss36 boot_FUN_RE RE_boot37 LocalIP string38)39type Boot_Node_info struct {40 Nodeid string41 Ip string42}43const (44 Time_Out_Limit = 10 * time.Second45 Find_Conn_Status_Interval = 546)47type GetHeightReq struct { //0x000148}49type GetHeightRsp struct { //0x000250 BlockHeight uint6451}52type GetMainNodeReq struct { //0x000353}54type GetMainNodeRsp struct { //0x000455 MainNode []election.NodeInfo56}57type RE_boot struct {58 Net_Flag int59 Height uint6460 Main_List []election.NodeInfo61}62type LocalHeightInfo struct {63 Ip string64 Len uint6465}66type Bc_Scheduler struct {67 P_blockchain *core.BlockChain68 P_scheduler *scheduler.Scheduler69}70type bootss struct {71 Mine_Bc_Scheduler Bc_Scheduler72 ChanSend chan []p2p.Custsend73 ChanHeight chan LocalHeightInfo74 ChanMainNode chan []election.NodeInfo75}76func (this *bootss) Read_Chan() {77 for {78 res := <-go_bootss.ChanSend79 p2p.CustSend(res)80 }81}82func getip() (string, error) {83 conn, err := net.Dial("udp", "google.com:80")84 if err != nil {85 return "", fmt.Errorf("can not get loacl ip")86 }87 defer conn.Close()88 ans := strings.Split(conn.LocalAddr().String(), ":")[0]89 return ans, nil90}91func Is_in_Need_Ack(index uint64) int {92 for i := 0; i < len(Need_Ack); i++ {93 if Need_Ack[i] == index {94 Need_Ack = append(Need_Ack[:i], Need_Ack[i+1:]...)95 return i96 }97 }98 return -199}100func (this *bootss) Get_local_block_height() uint64 {101 ss := go_bootss.Mine_Bc_Scheduler.P_blockchain.CurrentBlock().Header().Number.Uint64()102 return ss103}104func (this *bootss) Get_Mine_Main_Node() []election.NodeInfo {105 ss, _ := go_bootss.Mine_Bc_Scheduler.P_scheduler.Getmainnodelist()106 return ss107}108func Attept_Check_Not_Big_Than_Me(ListIp []string) {109 for {110 count := 0111 var ListIp_Conn_Status []p2p.Status_Re = p2p.CustStat(ListIp)112 for i := 0; i < len(ListIp_Conn_Status); i++ {113 if ListIp_Conn_Status[i].Ip_status {114 count++115 }116 }117 fmt.Println("ListIp_Conn_Status", ListIp_Conn_Status)118 if count == 2 {119 var ss_re []uint64120 var Status_Re int121 Status_Re, ss_re = go_bootss.Get_Block_Height(ListIp)122 if Status_Re == 1 {123 if ss_re[0] >= go_bootss.Get_local_block_height() || ss_re[1] >= go_bootss.Get_local_block_height() {124 var Main_List [][]election.NodeInfo125 Status_Re, Main_List = go_bootss.Get_Main_Node(ListIp)126 if Status_Re == 1 {127 boot_FUN_RE.Net_Flag = 1128 boot_FUN_RE.Height = ss_re[0]129 boot_FUN_RE.Main_List = Main_List[0]130 break131 }132 }133 }134 }135 time.Sleep(Find_Conn_Status_Interval * time.Second)136 log.Info("BOOT", "default node sleep end three node height not all zero")137 }138}139func Not_Default_Boot(ListIp []string) {140 for {141 count := 0142 var ListIp_Conn_Status []p2p.Status_Re = p2p.CustStat(ListIp)143 for i := 0; i < len(ListIp_Conn_Status); i++ {144 if ListIp_Conn_Status[i].Ip_status {145 count++146 }147 }148 fmt.Println("ListIp_Conn_Status", ListIp_Conn_Status)149 if count >= 2 {150 var ss_re []uint64151 var Status_Re int152 var Chose_Two_Boot []string153 for i := 0; i < len(ListIp_Conn_Status); i++ {154 if ListIp_Conn_Status[i].Ip_status {155 Chose_Two_Boot = append(Chose_Two_Boot, ListIp_Conn_Status[i].Ip)156 }157 if len(Chose_Two_Boot) >= 2 {158 break159 }160 }161 Status_Re, ss_re = go_bootss.Get_Block_Height(Chose_Two_Boot)162 if Status_Re == 1 {163 if ss_re[0] >= go_bootss.Get_local_block_height() || ss_re[1] >= go_bootss.Get_local_block_height() {164 var Main_List [][]election.NodeInfo165 Status_Re, Main_List = go_bootss.Get_Main_Node(Chose_Two_Boot)166 if Status_Re == 1 {167 boot_FUN_RE.Net_Flag = 1168 boot_FUN_RE.Height = ss_re[0]169 boot_FUN_RE.Main_List = Main_List[0]170 break171 }172 }173 }174 }175 time.Sleep(Find_Conn_Status_Interval * time.Second)176 log.Info("BOOT", "not default sleep end find two boot node")177 }178}179func Default_Boot_Find_Two_Boot(ListIp []string) int {180 for {181 count := 0182 var ListIp_Conn_Status []p2p.Status_Re = p2p.CustStat(ListIp)183 for i := 0; i < len(ListIp_Conn_Status); i++ {184 if ListIp_Conn_Status[i].Ip_status {185 count++186 }187 }188 fmt.Println("ListIp_Conn_Status", ListIp_Conn_Status)189 if count >= 2 {190 var Re_Height_List []uint64191 var Status_Re_Height int192 Status_Re_Height, Re_Height_List = go_bootss.Get_Block_Height(ListIp)193 if Status_Re_Height == 1 {194 if Re_Height_List[0] == 0 && Re_Height_List[1] == 0 && go_bootss.Get_local_block_height() == 0 {195 return 1196 } else {197 return 0198 }199 }200 }201 time.Sleep(Find_Conn_Status_Interval * time.Second)202 log.Info("BOOT", "default node sleep end heck other is zero")203 }204 return 0205}206func Make_Send_Msg(fromip string, toip string, istcp bool, code uint64, Type uint64) p2p.Custsend {207 var t p2p.Custsend208 t.FromIp = fromip209 t.ToIp = toip210 t.IsTcp = istcp211 t.Code = code212 var t_data_format p2p.Data_Format213 t_data_format.Type = Type214 t_data_format.Seq = Public_Seq215 Public_Seq = Public_Seq + 1216 switch Type {217 case 0x0001:218 var tt GetHeightReq219 t_data_format.Data_struct, _ = json.MarshalIndent(tt, "", " ")220 case 0x0003:221 var tt GetMainNodeReq222 t_data_format.Data_struct, _ = json.MarshalIndent(tt, "", " ")223 default:224 log.Info("BOOT", "Make_Send_Msg err Type=", Type)225 }226 t.Data = t_data_format227 return t228}229func (this *bootss) Get_Main_Node(ListIp_string []string) (int, [][]election.NodeInfo) { //获取主节点信息230 var t_Send []p2p.Custsend231 var Me_Need_Ack []uint64232 for i := 0; i < len(ListIp_string); i++ {233 t := Make_Send_Msg(LocalIP, ListIp_string[i], true, 1, 0x0003)234 t_Send = append(t_Send, t)235 Need_Ack = append(Need_Ack, t.Data.Seq)236 Me_Need_Ack = append(Me_Need_Ack, t.Data.Seq)237 }238 go_bootss.ChanSend <- t_Send239 var tt [][]election.NodeInfo240 for i := 0; i < len(Me_Need_Ack); i++ {241 select {242 case res := <-go_bootss.ChanMainNode:243 tt = append(tt, res)244 case <-time.After(Time_Out_Limit):245 log.Info("get main node failed")246 }247 }248 for i := 0; i < len(Me_Need_Ack); i++ {249 Is_in_Need_Ack(Me_Need_Ack[i])250 }251 if len(tt) < 2 {252 return 0, tt253 } else {254 return 1, tt255 }256}257func (this *bootss) Get_Block_Height(list_Ip_string []string) (int, []uint64) {258 var t_Send []p2p.Custsend259 var Me_Need_Ack []uint64260 for i := 0; i < len(list_Ip_string); i++ {261 t := Make_Send_Msg(LocalIP, list_Ip_string[i], true, 1, 0x0001)262 t_Send = append(t_Send, t)263 Need_Ack = append(Need_Ack, t.Data.Seq)264 Me_Need_Ack = append(Me_Need_Ack, t.Data.Seq)265 }266 go_bootss.ChanSend <- t_Send267 var tt []uint64268 for i := 0; i < 2; i++ {269 select {270 case res := <-go_bootss.ChanHeight:271 tt = append(tt, res.Len)272 case <-time.After(Time_Out_Limit):273 log.Info("BOOT", "get height failed")274 }275 }276 for i := 0; i < len(Me_Need_Ack); i++ {277 Is_in_Need_Ack(Me_Need_Ack[i])278 }279 if len(tt) < 2 {280 return 0, tt281 } else {282 return 1, tt283 }284}285func (this *bootss) init(s *eth.Ethereum) {286 this.Mine_Bc_Scheduler.P_blockchain = s.BlockChain()287 this.Mine_Bc_Scheduler.P_scheduler = s.Scheduler288 this.ChanSend = make(chan []p2p.Custsend, 100)289 this.ChanHeight = make(chan LocalHeightInfo)290 this.ChanMainNode = make(chan []election.NodeInfo)291}292func Touch_And_Analy_1(bb interface{}, cc p2p.Custsend) {293 Re_Analy_Data := cc294 switch Re_Analy_Data.Data.Type {295 case 0x0001:296 fmt.Println("0x0001")297 var t GetHeightRsp298 t.BlockHeight = go_bootss.Get_local_block_height()299 data, err := json.MarshalIndent(t, "", " ")300 if err != nil {301 log.Info("BOOT", "json 0x0001 Marshaling failed")302 }303 Re_Analy_Data.Data.Data_struct = data304 Re_Analy_Data.Data.Type = 0x0002305 Re_Analy_Data.FromIp, Re_Analy_Data.ToIp = Re_Analy_Data.ToIp, Re_Analy_Data.FromIp306 var send []p2p.Custsend307 send = append(send, Re_Analy_Data)308 go_bootss.ChanSend <- send309 case 0x0002:310 fmt.Println("0x0002")311 if Is_in_Need_Ack(Re_Analy_Data.Data.Seq) != -1 {312 var aa LocalHeightInfo313 aa.Ip = Re_Analy_Data.FromIp314 var re_a GetHeightRsp315 if err := json.Unmarshal(Re_Analy_Data.Data.Data_struct, &re_a); err != nil {316 log.Info("BOOT", "Unmarshal failed err=", err)317 }318 aa.Len = re_a.BlockHeight319 go_bootss.ChanHeight <- aa320 } else {321 fmt.Println("BOOT", "0x0002 overtime height comming")322 }323 case 0x0003:324 fmt.Println("0x0003")325 var t GetMainNodeRsp326 t.MainNode = go_bootss.Get_Mine_Main_Node()327 data, err := json.MarshalIndent(t, "", " ")328 if err != nil {329 log.Info("BOOT", "json 0x0003 Marshaling failed")330 }331 Re_Analy_Data.Data.Data_struct = data332 Re_Analy_Data.Data.Type = 0x0004333 Re_Analy_Data.FromIp, Re_Analy_Data.ToIp = Re_Analy_Data.ToIp, Re_Analy_Data.FromIp334 var Send_Main_Node []p2p.Custsend335 Send_Main_Node = append(Send_Main_Node, Re_Analy_Data)336 go_bootss.ChanSend <- Send_Main_Node337 case 0x0004:338 fmt.Println("0x0004")339 if Is_in_Need_Ack(Re_Analy_Data.Data.Seq) != -1 {340 var aa_4 []election.NodeInfo341 var re_aa GetMainNodeRsp342 if err := json.Unmarshal(Re_Analy_Data.Data.Data_struct, &re_aa); err != nil {343 log.Info("BOOT", "Unmarshal failed err=", err)344 }345 aa_4 = re_aa.MainNode346 go_bootss.ChanMainNode <- aa_4347 } else {348 fmt.Println("BOOT", "0x0004 overtime MainNode comming")349 }350 }351}352func Analy_Boot_Node(boot_node []string) []Boot_Node_info {353 var rr []Boot_Node_info354 for i := 0; i < len(boot_node); i++ {355 start := 0356 end := 0357 for j := 0; j < len(boot_node[i]); j++ {358 if boot_node[i][j] == '@' {359 start = j360 }361 if boot_node[i][j] == ':' {362 end = j363 }364 }365 var t Boot_Node_info366 t.Nodeid = boot_node[i][8:start]367 t.Ip = boot_node[i][start+1 : end]368 rr = append(rr, t)369 }370 return rr371}372func NetSearch(s *eth.Ethereum) RE_boot {373 boot_node := params.MainnetBootnodes374 boot_ip := Analy_Boot_Node(boot_node)375 go_bootss.init(s)376 sp2p := p2p.Slove_Cycle{}377 sp2p.Register_boot(Touch_And_Analy_1, go_bootss)378 go go_bootss.Read_Chan()379 for {380 var err error381 LocalIP, err = getip()382 if err != nil {383 log.Error("BOOT", " get local ip err err=", err)384 time.Sleep(2 * time.Second)385 continue386 }387 if len(LocalIP) != 0 {388 break389 } else {390 log.Error("BOOT", " err local ip! ip=", LocalIP)391 time.Sleep(2 * time.Second)392 }393 }394 log.Info("BOOT", "localip=", LocalIP)395 flag_default_boot := -1396 for i := 0; i < len(boot_ip); i++ {397 if LocalIP == boot_ip[i].Ip {398 flag_default_boot = i399 }400 }401 if flag_default_boot != -1 {402 log.Info("BOOT", "---is default---")403 var need_find_ip []string404 for i := 0; i < 3; i++ {405 if i != flag_default_boot {406 need_find_ip = append(need_find_ip, boot_ip[i].Ip)407 }408 }409 is_all_zero := Default_Boot_Find_Two_Boot(need_find_ip)410 if is_all_zero == 1 {411 var Main_List [][]election.NodeInfo412 var Status_Re_Main_Node int413 for true {414 Status_Re_Main_Node, Main_List = go_bootss.Get_Main_Node(need_find_ip)415 if Status_Re_Main_Node == 1 {416 Is_All_List_Empty := 1417 for i := 0; i < len(Main_List); i++ {418 if len(Main_List[i]) != 0 {419 Is_All_List_Empty = 0420 }421 }422 if Is_All_List_Empty == 1 {423 boot_FUN_RE.Net_Flag = 0424 } else {425 boot_FUN_RE.Net_Flag = 0426 }427 break428 } else {429 log.Info("three node height all zero to get mainlistnode")430 time.Sleep(Time_Out_Limit)431 }432 }433 } else {434 Attept_Check_Not_Big_Than_Me(need_find_ip)435 }436 } else {437 var need_find_ip_not_default []string438 for i := 0; i < len(boot_ip); i++ {439 need_find_ip_not_default = append(need_find_ip_not_default, boot_ip[i].Ip)440 }441 Not_Default_Boot(need_find_ip_not_default)442 }443 log.Info("BOOT", "boot_FUN_RE.Net_Flag", boot_FUN_RE.Net_Flag, "boot_FUN_RE.Height", boot_FUN_RE.Height, "boot_FUN_RE.Main_List", boot_FUN_RE.Main_List)444 return boot_FUN_RE445}...

Full Screen

Full Screen

boot_mode.go

Source:boot_mode.go Github

copy

Full Screen

...12 "chromiumos/tast/remote/firmware/fixture"13 "chromiumos/tast/remote/firmware/reporters"14 "chromiumos/tast/testing"15)16// bootModeTestParams defines the params for a single test-case.17// bootToMode defines which boot-mode to switch the DUT into.18// allowGBBForce defines whether to force dev mode via GBB flags.19// resetAfterBoot defines whether to perform a ModeAwareReboot after switching to bootToMode.20// resetType defines whether ModeAwareReboot should use a warm or a cold reset.21// checkBootFromMain checks whether device boots from the main storage when a memory device is attached.22type bootModeTestParams struct {23 bootToMode fwCommon.BootMode24 allowGBBForce bool25 resetAfterBoot bool26 resetType firmware.ResetType27 checkBootFromMain bool28}29func init() {30 testing.AddTest(&testing.Test{31 Func: BootMode,32 Desc: "Verifies that remote tests can boot the DUT into, and confirm that the DUT is in, the different firmware modes (normal, dev, and recovery)",33 Contacts: []string{"cros-fw-engprod@google.com"},34 Attr: []string{"group:firmware"},35 SoftwareDeps: []string{"crossystem", "flashrom"},36 Vars: []string{"firmware.skipFlashUSB"},37 Params: []testing.Param{{38 Name: "normal_warm",39 Fixture: fixture.NormalMode,40 Val: bootModeTestParams{41 resetAfterBoot: true,42 resetType: firmware.WarmReset,43 },44 ExtraAttr: []string{"firmware_smoke"},45 Timeout: 15 * time.Minute,46 }, {47 Name: "normal_cold",48 Fixture: fixture.NormalMode,49 Val: bootModeTestParams{50 resetAfterBoot: true,51 resetType: firmware.ColdReset,52 },53 ExtraAttr: []string{"firmware_smoke"},54 Timeout: 15 * time.Minute,55 }, {56 Name: "rec_warm",57 Fixture: fixture.NormalMode,58 Val: bootModeTestParams{59 bootToMode: fwCommon.BootModeRecovery,60 resetAfterBoot: true,61 resetType: firmware.WarmReset,62 },63 ExtraAttr: []string{"firmware_smoke", "firmware_usb"},64 Timeout: 60 * time.Minute,65 }, {66 Name: "rec_cold",67 Fixture: fixture.NormalMode,68 Val: bootModeTestParams{69 bootToMode: fwCommon.BootModeRecovery,70 resetAfterBoot: true,71 resetType: firmware.ColdReset,72 },73 ExtraAttr: []string{"firmware_smoke", "firmware_usb"},74 Timeout: 60 * time.Minute,75 }, {76 Name: "dev_usb_cold",77 Fixture: fixture.USBDevModeNoServices,78 Val: bootModeTestParams{79 resetAfterBoot: true,80 resetType: firmware.ColdReset,81 },82 ExtraAttr: []string{"firmware_usb", "firmware_unstable"},83 Timeout: 60 * time.Minute,84 }, {85 Name: "dev_warm",86 Fixture: fixture.DevMode,87 Val: bootModeTestParams{88 resetAfterBoot: true,89 resetType: firmware.WarmReset,90 checkBootFromMain: true,91 },92 ExtraAttr: []string{"firmware_smoke", "firmware_usb"},93 Timeout: 60 * time.Minute,94 }, {95 Name: "dev_cold",96 Fixture: fixture.DevMode,97 Val: bootModeTestParams{98 resetAfterBoot: true,99 resetType: firmware.ColdReset,100 checkBootFromMain: true,101 },102 ExtraAttr: []string{"firmware_smoke", "firmware_usb"},103 Timeout: 60 * time.Minute,104 }, {105 Name: "dev_to_rec",106 Fixture: fixture.DevMode,107 Val: bootModeTestParams{108 bootToMode: fwCommon.BootModeRecovery,109 },110 ExtraAttr: []string{"firmware_smoke", "firmware_usb"},111 Timeout: 60 * time.Minute,112 }, {113 Name: "rec_to_dev",114 Fixture: fixture.RecModeNoServices,115 Val: bootModeTestParams{116 bootToMode: fwCommon.BootModeDev,117 },118 ExtraAttr: []string{"firmware_unstable", "firmware_usb"},119 Timeout: 60 * time.Minute,120 }, {121 Name: "dev_gbb_to_rec",122 Fixture: fixture.DevModeGBB,123 Val: bootModeTestParams{124 bootToMode: fwCommon.BootModeRecovery,125 },126 ExtraAttr: []string{"firmware_unstable", "firmware_usb"},127 Timeout: 60 * time.Minute,128 }, {129 Name: "rec_to_dev_gbb",130 Fixture: fixture.RecModeNoServices,131 Val: bootModeTestParams{132 bootToMode: fwCommon.BootModeDev,133 allowGBBForce: true,134 },135 ExtraAttr: []string{"firmware_unstable", "firmware_usb"},136 Timeout: 60 * time.Minute,137 }, {138 // Verifies that we can go from normal -> dev -> normal without GBB flags.139 Name: "normal_dev",140 Fixture: fixture.NormalMode,141 Val: bootModeTestParams{142 bootToMode: fwCommon.BootModeDev,143 allowGBBForce: false,144 resetAfterBoot: false,145 },146 ExtraAttr: []string{"firmware_bios", "firmware_level2"},147 Timeout: 15 * time.Minute,148 }},149 })150}151func BootMode(ctx context.Context, s *testing.State) {152 tc := s.Param().(bootModeTestParams)153 pv := s.FixtValue().(*fixture.Value)154 h := pv.Helper155 if err := h.RequireServo(ctx); err != nil {156 s.Fatal("Failed to init servo: ", err)157 }158 ms, err := firmware.NewModeSwitcher(ctx, h)159 if err != nil {160 s.Fatal("Creating mode switcher: ", err)161 }162 // Report ModeSwitcherType, for debugging.163 if err := h.RequireConfig(ctx); err != nil {164 s.Fatal("Requiring config")165 }166 s.Log("Mode switcher type: ", h.Config.ModeSwitcherType)167 if err := h.RequireServo(ctx); err != nil {168 s.Fatal("Error opening servo: ", err)169 }170 if tc.bootToMode == fwCommon.BootModeRecovery || tc.checkBootFromMain {171 skipFlashUSB := false172 if skipFlashUSBStr, ok := s.Var("firmware.skipFlashUSB"); ok {173 skipFlashUSB, err = strconv.ParseBool(skipFlashUSBStr)174 if err != nil {175 s.Fatalf("Invalid value for var firmware.skipFlashUSB: got %q, want true/false", skipFlashUSBStr)176 }177 }178 cs := s.CloudStorage()179 if skipFlashUSB {180 cs = nil181 }182 if err := h.SetupUSBKey(ctx, cs); err != nil {183 s.Fatal("USBKey not working: ", err)184 }185 }186 // Double-check that DUT starts in the right mode.187 if curr, err := h.Reporter.CurrentBootMode(ctx); err != nil {188 s.Fatal("Checking boot mode at beginning of test: ", err)189 } else if curr != pv.BootMode {190 s.Logf("DUT started in boot mode %s. Setting up %s", curr, pv.BootMode)191 if err = ms.RebootToMode(ctx, pv.BootMode); err != nil {192 s.Fatalf("Failed to set up %s mode: %s", pv.BootMode, err)193 }194 }195 if tc.bootToMode != "" {196 // Switch to tc.bootToMode.197 // RebootToMode ensures that the DUT winds up in the expected boot mode afterward.198 var opts []firmware.ModeSwitchOption199 if tc.allowGBBForce {200 opts = append(opts, firmware.AllowGBBForce)201 } else if !pv.ForcesDevMode {202 // Don't check the dev-force GBB flag if there's no reason for it to have been set.203 opts = append(opts, firmware.AssumeGBBFlagsCorrect)204 }205 s.Logf("Transitioning to %s mode with options %+v", tc.bootToMode, opts)206 if err = ms.RebootToMode(ctx, tc.bootToMode, opts...); err != nil {207 s.Fatalf("Error during transition from %s to %s: %+v", pv.BootMode, tc.bootToMode, err)208 }209 s.Log("Transition completed successfully")210 }211 // Reset the DUT, if the test case calls for it.212 // ModeAwareReboot ensures the DUT winds up in the expected boot mode afterward.213 if tc.resetAfterBoot {214 s.Logf("Resetting DUT (resetType=%v)", tc.resetType)215 if err := ms.ModeAwareReboot(ctx, tc.resetType); err != nil {216 s.Fatal("Error resetting DUT: ", err)217 }218 // See the doc for ModeAwareReboot, the boot mode should be unchanged except that Recovery goes to normal.219 if curr, err := h.Reporter.CurrentBootMode(ctx); err != nil {220 s.Fatal("Failed to determine DUT boot mode: ", err)221 } else if curr != pv.BootMode && pv.BootMode != fwCommon.BootModeRecovery {222 s.Fatalf("Wrong boot mode: got %q, want %q", curr, pv.BootMode)223 } else if curr != fwCommon.BootModeNormal && pv.BootMode == fwCommon.BootModeRecovery {224 s.Fatalf("Wrong boot mode: got %q, want %q", curr, fwCommon.BootModeNormal)225 }226 s.Log("Reset completed successfully")227 } else {228 // Verify the boot mode and then reboot to normal.229 if curr, err := h.Reporter.CurrentBootMode(ctx); err != nil {230 s.Fatal("Failed to determine DUT boot mode: ", err)231 } else if curr != tc.bootToMode {232 s.Fatalf("Wrong boot mode: got %q, want %q", curr, pv.BootMode)233 } else if curr != fwCommon.BootModeNormal {234 s.Logf("Transitioning back from %s to normal mode", curr)235 if err = ms.RebootToMode(ctx, fwCommon.BootModeNormal); err != nil {236 s.Fatalf("Error returning from %s to %s: %+v", curr, fwCommon.BootModeNormal, err)237 }238 s.Log("Transition completed successfully")239 }240 }241 // Check that DUT can boot from the main storage despite USB device attached.242 if tc.checkBootFromMain {243 // Ensure that mainfw_act returns A, and if not set up crossystem param244 // for the device to boot from firmware A next time.245 mainfwAct, err := h.Reporter.CrossystemParam(ctx, reporters.CrossystemParamMainfwAct)246 if err != nil {247 s.Fatal("Failed to get crossystem mainfw_act: ", err)248 }249 if mainfwAct != "A" {250 s.Log("Current mainfw_act not set to A. Attempting to set the device to boot from A during next reboot")251 if err := h.DUT.Conn().CommandContext(ctx, "crossystem", "fw_try_next=A").Run(); err != nil {252 s.Fatal("Failed to set 'crossystem fw_try_next=A': ", err)253 }254 }255 s.Log("Enabling USB connection to DUT")256 if err := h.Servo.SetUSBMuxState(ctx, servo.USBMuxDUT); err != nil {257 s.Fatal("Failed to set 'usb3_mux_sel:dut_sees_usbkey': ", err)258 }259 s.Log("Power-cycling DUT with a warm reset")260 if err := h.Servo.SetPowerState(ctx, servo.PowerStateWarmReset); err != nil {261 s.Fatal("Failed to reboot DUT by servo: ", err)262 }263 s.Log("Waiting for DUT to power ON")264 waitConnectCtx, cancelWaitConnect := context.WithTimeout(ctx, 2*time.Minute)265 defer cancelWaitConnect()266 if err := s.DUT().WaitConnect(waitConnectCtx); err != nil {267 s.Fatal("Failed to reconnect to DUT: ", err)268 }269 s.Log("Checking that DUT has booted from main")270 bootedDeviceType, err := h.Reporter.BootedDevice(ctx)271 if err != nil {272 s.Fatal("Could not determine boot device type: ", err)273 }274 if bootedDeviceType != reporters.BootedDeviceDeveloperInternalSig {275 s.Fatalf("DUT did not boot from the internal device, and got bootedDeviceType:%v", bootedDeviceType)276 }277 s.Log("Checking the value of mainfw_act after reboot")278 mainfwAct, err = h.Reporter.CrossystemParam(ctx, reporters.CrossystemParamMainfwAct)279 if err != nil {280 s.Fatal("Failed to get crossystem mainfw_act: ", err)281 }282 if mainfwAct != "A" {283 s.Fatalf("Expected mainfw_act:A but got mainfw_act:%s", mainfwAct)284 }285 }286}...

Full Screen

Full Screen

base.go

Source:base.go Github

copy

Full Screen

...18}19func (d *dap) DAppP() error {20 for {21 select {22 case e := <-d.boot.UI.Window.Events():23 switch e := e.(type) {24 case system.DestroyEvent:25 return e.Err26 case system.FrameEvent:27 gtx := layout.NewContext(&d.boot.UI.Ops, e)28 d.BeforeMain(&gtx)29 lyt.Format(gtx, "max(inset(0dp0dp0dp0dp,_))", d.Main())30 d.AfterMain(&gtx)31 e.Frame(gtx.Ops)32 }33 d.boot.UI.Window.Invalidate()34 }35 }36}37func (d *dap) BeforeMain(gtx *C) {38 d.boot.UI.R = res.Resposnsivity(gtx.Constraints.Max.X, gtx.Constraints.Max.Y)39 d.boot.UI.N.Mode = d.boot.UI.R.Mode40 d.boot.UI.N.NavLayout = d.boot.UI.R.Mod["Nav"].(string)41 d.boot.UI.N.ItemLayout = d.boot.UI.R.Mod["NavIconAndLabel"].(string)42 d.boot.UI.N.Axis = d.boot.UI.R.Mod["NavItemsAxis"].(layout.Axis)43 d.boot.UI.N.Size = d.boot.UI.R.Mod["NavSize"].(int)44 d.boot.UI.N.NoContent = d.boot.UI.N.Wide45 d.boot.UI.N.LogoWidget = d.boot.UI.N.LogoLayout(d.boot.UI.Theme)46}47func (d *dap) AfterMain(gtx *C) {48 //pop.Popup(gtx, d.boot.UI.Theme, func(gtx C)D{return material.H3(d.boot.UI.Theme.T,"tetstette").Layout(gtx)})49 //return lyt.Format(gtx, "hflex(middle,f(1,inset(8dp8dp8dp8dp,_)))",50 //pop.Popup(d.boot.UI.Theme, func(gtx C) D {51 // title := theme.Body(d.boot.UI.Theme, "Requested payments history")52 // title.Alignment = text.Start53 // return title.Layout(gtx)54 // }),55 //})56}57func Tik(d *dap) func() {58 return func() {59 //gw := d.boot.Apps["ParallelCoinWallet"].App.(gwallet.GioWallet)60 //gw.GetBalances()61 //gw.GetLatestTransactions()62 }63}64func ticker(f func()) {65 ticker := time.NewTicker(1 * time.Second)66 quit := make(chan struct{})67 go func() {68 for {69 select {70 case <-ticker.C:71 f()72 case <-quit:73 ticker.Stop()74 return75 }76 }77 }()78}79func (d *dap) Main() W {80 return func(gtx C) D {81 return lyt.Format(gtx, d.boot.UI.R.Mod["Container"].(string),82 box.BoxBase(d.boot.UI.Theme.Colors["NavBg"], d.boot.UI.N.Nav(d.boot.UI.Theme, gtx)),83 func(gtx C) D {84 return lyt.Format(gtx, d.boot.UI.R.Mod["Main"].(string),85 d.boot.UI.N.CurrentPage.P(d.boot.UI.Theme, d.boot.UI.R.Mod["Page"].(string)),86 d.boot.UI.F,87 )88 })89 }90}...

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import "fmt"2func main() {3 fmt.Println("hello world")4}5import "fmt"6func main() {7 fmt.Println("hello world")8}9import "fmt"10func main() {11 fmt.Println("hello world")12}13import "fmt"14func main() {15 fmt.Println("hello world")16}17import "fmt"18func main() {19 fmt.Println("hello world")20}21import "fmt"22func main() {23 fmt.Println("hello world")24}25import "fmt"26func main() {27 fmt.Println("hello world")28}29import "fmt"30func main() {31 fmt.Println("hello world")32}33import "fmt"34func main() {35 fmt.Println("hello world")36}37import "fmt"38func main() {39 fmt.Println("hello world")40}41import "fmt"42func main() {43 fmt.Println("hello world")44}45import "fmt"46func main() {47 fmt.Println("hello world")48}49import "fmt"50func main() {51 fmt.Println("hello world")52}53import "fmt"54func main() {55 fmt.Println("hello world")56}57import "fmt"

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 logs.SetLogger(logs.AdapterFile, `{"filename":"logs/test2.log","level":7,"maxlines":0,"maxsize":0,"daily":true,"maxdays":10,"color":true}`)4 logs.Debug("use file log")5 logs.Trace("trace")6 logs.Info("info")7 logs.Warn("warning")8 logs.Error("error")9 logs.Critical("crit")10 fmt.Println("test2")11}

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import (2type mainClass struct {3}4func (m mainClass) boot() {5 fmt.Println("Boot method of main class")6}7type subClass struct {8}9func (s subClass) boot() {10 fmt.Println("Boot method of sub class")11}12func main() {13 s := subClass{}14 s.boot()15}

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import "fmt"2type boot struct {3}4func (b boot) start() {5 fmt.Println(b.bootName, "Booting...")6}7func (b boot) stop() {8 fmt.Println(b.bootName, "Stopping...")9}10func main() {11 b := boot{12 }13 b.start()14 b.stop()15}

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello World!")4 fmt.Println("Hello World!")5 fmt.Println("Hello World!")6 os.Exit(1)7}8import (9func main() {10 fmt.Println("Hello World!")11 fmt.Println("Hello World!")12 fmt.Println("Hello World!")13 os.Exit(1)14}15import (16func main() {17 fmt.Println("Hello World!")18 fmt.Println("Hello World!")19 fmt.Println("Hello World!")20 os.Exit(1)21}22import (23func main() {24 fmt.Println("Hello World!")25 fmt.Println("Hello World!")26 fmt.Println("Hello World!")27 os.Exit(1)28}29import (30func main() {31 fmt.Println("Hello World!")32 fmt.Println("Hello World!")33 fmt.Println("Hello World!")34 os.Exit(1)35}36import (37func main() {38 fmt.Println("Hello World!")39 fmt.Println("Hello World!")40 fmt.Println("Hello World!")41 os.Exit(1)42}43import (44func main() {45 fmt.Println("Hello World!")46 fmt.Println("Hello World!")47 fmt.Println("Hello World!")48 os.Exit(1)49}50import (51func main() {52 fmt.Println("Hello World!")53 fmt.Println("Hello World!")54 fmt.Println("Hello World!")55 os.Exit(1)56}57import (58func main() {59 fmt.Println("Hello World!")60 fmt.Println("Hello World!")61 fmt.Println("Hello World!")62 os.Exit(1)63}

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println(runtime.GOOS)5 fmt.Println(runtime.GOARCH)6 fmt.Println(runtime.GOOS)7 fmt.Println(runtime.GOARCH)

Full Screen

Full Screen

boot

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("This is the main class")4 boot()5}6func boot() {7 fmt.Println("This is the boot class")8}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Syzkaller automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful