[DESCRIPTION]
CtsNetTestCases android.net.wifi.cts.NsdManagerTest#testNDSManager
04-05 15:12:49 I/ConsoleReporter: [1/1 arm64-v8a CtsNetTestCases HGAE5WKC] android.net.wifi.cts.NsdManagerTest#testNDSManager fail: junit.framework.AssertionFailedError
at junit.framework.Assert.fail(Assert.java:48)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertTrue(Assert.java:27)
at android.net.wifi.cts.NsdManagerTest.testNDSManager(NsdManagerTest.java:361)
at java.lang.reflect.Method.invoke(Native Method)
at junit.framework.Assert.fail(Assert.java:48)
at junit.framework.Assert.assertTrue(Assert.java:20)
at junit.framework.Assert.assertTrue(Assert.java:27)
at android.net.wifi.cts.NsdManagerTest.testNDSManager(NsdManagerTest.java:361)
at java.lang.reflect.Method.invoke(Native Method)
[SOLUTION]
这题原本是google issue;Google bug ID:64733563
可以参考如下workround方法:
- 将下面红色背景的code修改成绿色背景的code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
10610mDNSexport mStatus mDNS_Init(mDNS *const m, mDNS_PlatformSupport *const p, 10611 CacheEntity *rrcachestorage, mDNSu32 rrcachesize, 10612 mDNSBool AdvertiseLocalAddresses, mDNSCallback *Callback, void *Context) 10613 { 10614 mDNSu32 slot; 10615 mDNSs32 timenow; 10616 mStatus result; 10617 10618 if (!rrcachestorage) rrcachesize = 0; 10619 10620 m->p = p; 10621 m->KnownBugs = 0; 10622 m->CanReceiveUnicastOn5353 = mDNSfalse; // Assume we can't receive unicasts on 5353, unless platform layer tells us otherwise 10623 m->AdvertiseLocalAddresses = AdvertiseLocalAddresses; 10624 m->DivertMulticastAdvertisements = mDNSfalse; 10625 m->mDNSPlatformStatus = mStatus_Waiting; 10626 m->UnicastPort4 = zeroIPPort; 10627 m->UnicastPort6 = zeroIPPort; 10628 m->PrimaryMAC = zeroEthAddr; 10629 m->MainCallback = Callback; 10630 m->MainContext = Context; 10631 m->rec.r.resrec.RecordType = 0; 10632 10633 // For debugging: To catch and report locking failures 10634 m->mDNS_busy = 0; 10635 m->mDNS_reentrancy = 0; 10636 m->ShutdownTime = 0; 10637 m->lock_rrcache = 0; 10638 m->lock_Questions = 0; 10639 m->lock_Records = 0; 10640 10641 // Task Scheduling variables 10642 result = mDNSPlatformTimeInit(); 10643 if (result != mStatus_NoError) return(result); 10644 //m->timenow_adjust = 0; // b/63335997 , High outbound network traffic m->timenow_adjust =(mDNSs32)(0x90000000 + (unsigned int) mDNSRandom(0x0FFFFFFF)); 10645 timenow = mDNS_TimeNow_NoLock(m); 10646 10647 m->timenow = 0; // MUST only be set within mDNS_Lock/mDNS_Unlock section 10648 m->timenow_last = timenow; 10649 m->NextScheduledEvent = timenow; 10650 m->SuppressSending = timenow; 10651 m->NextCacheCheck = timenow + 0x78000000; 10652 m->NextScheduledQuery = timenow + 0x78000000; 10653 m->NextScheduledProbe = timenow + 0x78000000; 10654 m->NextScheduledResponse = timenow + 0x78000000; 10655 m->NextScheduledNATOp = timenow + 0x78000000; 10656 m->NextScheduledSPS = timenow + 0x78000000; 10657 m->NextScheduledStopTime = timenow + 0x78000000; 10658 m->RandomQueryDelay = 0; 10659 m->RandomReconfirmDelay = 0; 10660 m->PktNum = 0; 10661 m->LocalRemoveEvents = mDNSfalse; |
- 将下面红色背景的code修改成绿色背景的code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
1430mDNSexport mDNSs32 mDNSPlatformRawTime() 1431 { 1432 struct timeval tv; 1433 gettimeofday(&tv, NULL); 1434 // tv.tv_sec is seconds since 1st January 1970 (GMT, with no adjustment for daylight savings time) 1435 // tv.tv_usec is microseconds since the start of this second (i.e. values 0 to 999999) 1436 // We use the lower 22 bits of tv.tv_sec for the top 22 bits of our result 1437 // and we multiply tv.tv_usec by 16 / 15625 to get a value in the range 0-1023 to go in the bottom 10 bits. 1438 // This gives us a proper modular (cyclic) counter that has a resolution of roughly 1ms (actually 1/1024 second) 1439 // and correctly cycles every 2^22 seconds (4194304 seconds = approx 48 days). 1440 //return((tv.tv_sec << 10) | (tv.tv_usec * 16 / 15625)); return (((tv.tv_sec << 10) | (tv.tv_usec * 16 / 15625)) & 0x0FFFFFFF); 1441 } |