cl/429189577: Fix intermittent failures in various unit tests in EnclaveTest.
cl/429189577: Fix intermittent failures in various unit tests in EnclaveTest.

The root cause is an unintended side-effect of go/kcl/466292 which now defers
enclave destruction to a CFS task. Thus enclave destruction of a prior test
can now race with enclave creation of the next one.

The fix is to retry assignment of CPUs to a enclave a finite number of times
as long as the reason for failure is consistent with the race described above.

Reported by: jhumphri@

[ RUN      ] EnclaveTest.CleanupLeakedCpus
third_party/ghost/tests/enclave_test.cc:163(2329) CHECK FAILED: write(cpulist_fd, cpu.c_str(), cpu.length()) == cpu.length() [-1 != 1]
errno: 16 [Device or resource busy]
PID 2329 Backtrace:
[0] 0x555abf8c5425 : ghost::Exit()
[1] 0x555abf87cfc4 : ghost::(anonymous namespace)::AddCpu()
[2] 0x555abf87cc7c : ghost::(anonymous namespace)::MakeEnclaveAndLeakCpu1()
[3] 0x555abf8d4ce8 : testing::Test::Run()
[4] 0x555abf8d5b58 : testing::TestInfo::Run()
[5] 0x555abf8d6862 : testing::TestSuite::Run()
[6] 0x555abf8e7cef : testing::internal::UnitTestImpl::RunAllTests()
[7] 0x555abf8e6ec7 : testing::UnitTest::Run()
[8] 0x555abf8cabfd : main
[9] 0x7f27ca4968d3 : __libc_start_main
[10] 0x555abf8788ea : _start

TESTED=thousands of successful iterations of EnclaveTest in virtme

google/ghost-userspace,google/ghost-userspace,google/ghost-userspace,google/ghost-userspace