Unittest failed

31 views
Skip to first unread message

Nhan Nguyen

unread,
Nov 15, 2016, 1:30:14 PM11/15/16
to Omaha Discuss
Hi
I'm getting in a trouble with unittest. 
For more clearly, in the teardown function there is an error: RegKey::DeleteKey(kRegistryHiveOverrideRoot, true) failed with error 0x80070005

void RegistryProtectedTest::TearDown() {
  RestoreRegistryHives();
  ASSERT_SUCCEEDED(RegKey::DeleteKey(hive_override_key_name_, true));
}

The assertion is failed here.

I figured out that I have no access right to
HKEY_CURRENT_USER\SOFTWARE\CompanyName\Update\UnitTest\HKCU\Software\Microsoft\Windows\CurrentVersion\Run
so I even cannot delete it manually (directly in registry) (ERROR: Cannot Delete Run: Error while deleting key.)

I run unittest with admin privileges.

Any hints for me to pass this case?



Nhan Nguyen

unread,
Nov 17, 2016, 11:44:40 AM11/17/16
to Omaha Discuss
@Sorin:
Do you have any suggestion for me to walkaround this case? 
In almost of unittest, this registry key is created and deleted after each unittest related to registry.

Sorin Jianu

unread,
Nov 17, 2016, 2:10:02 PM11/17/16
to omaha-...@googlegroups.com
As far as I know we are not doing anything special related to ACLs on most registry keys. One idea would be to inspect the permissions on the registry key and understand why the key can't be deleted. I don't understand how the key has ended up in this state. I am thinking that deleting the key manually would help before the unit test can be run again.

--
You received this message because you are subscribed to the Google Groups "Omaha Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to omaha-...@googlegroups.com.
Visit this group at https://groups.google.com/group/omaha-discuss.
For more options, visit https://groups.google.com/d/optout.

Nhan Nguyen

unread,
Nov 18, 2016, 3:20:24 AM11/18/16
to Omaha Discuss
There's nothing special with key's permission or key's owner. 
I used psexec to delete the key manually. And the key was deleted successfully.
However in the next run of omaha_unittest, the key is created and cannot be deleted as above description again.
So I cannot guess what is wrong in this case. 
Maybe the key is occupied by unknown running process, so I cannot delete it manually?
Any idea?

On Friday, November 18, 2016 at 2:10:02 AM UTC+7, sorin wrote:
As far as I know we are not doing anything special related to ACLs on most registry keys. One idea would be to inspect the permissions on the registry key and understand why the key can't be deleted. I don't understand how the key has ended up in this state. I am thinking that deleting the key manually would help before the unit test can be run again.
On Thu, Nov 17, 2016 at 12:31 AM, Nhan Nguyen <nttnh...@gmail.com> wrote:
@Sorin:
Do you have any suggestion for me to walkaround this case? 
In almost of unittest, this registry key is created and deleted after each unittest related to registry.


On Wednesday, November 16, 2016 at 1:30:14 AM UTC+7, Nhan Nguyen wrote:
Hi
I'm getting in a trouble with unittest. 
For more clearly, in the teardown function there is an error: RegKey::DeleteKey(kRegistryHiveOverrideRoot, true) failed with error 0x80070005

void RegistryProtectedTest::TearDown() {
  RestoreRegistryHives();
  ASSERT_SUCCEEDED(RegKey::DeleteKey(hive_override_key_name_, true));
}

The assertion is failed here.

I figured out that I have no access right to
HKEY_CURRENT_USER\SOFTWARE\CompanyName\Update\UnitTest\HKCU\Software\Microsoft\Windows\CurrentVersion\Run
so I even cannot delete it manually (directly in registry) (ERROR: Cannot Delete Run: Error while deleting key.)

I run unittest with admin privileges.

Any hints for me to pass this case?



--
You received this message because you are subscribed to the Google Groups "Omaha Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-discus...@googlegroups.com.

Sorin Jianu

unread,
Nov 18, 2016, 5:58:51 PM11/18/16
to omaha-...@googlegroups.com
On Fri, Nov 18, 2016 at 12:16 AM, Nhan Nguyen <nttnh...@gmail.com> wrote:
There's nothing special with key's permission or key's owner.  
I used psexec to delete the key manually. And the key was deleted successfully.

Something must be special about permissions if we are not able to delete the key
as an elevated admin an we have to use psexec. The rest of the unittest code, which runs as an elevated admin won't be able to delete the key either, and perhaps that is why the code fails with the access denied error.
 
However in the next run of omaha_unittest, the key is created and cannot be deleted as above description again. 
So I cannot guess what is wrong in this case. 
Maybe the key is occupied by unknown running process, so I cannot delete it manually?

Regkeys don't behave like files in this respect as far as I know, so I assume this is not the reason.
 
Any idea?

It is possible that the key is created as part of some of our unit tests which use psexec to
run parts of the code as SYSTEM. It is possible that something fails inside that unit tests, which fails to clean up the key when the unit test is torn down. Therefore, subsequent unit tests, which don't use psexec, could fail, because they expected that the said key does not exist. 

One idea would be to identify which test creates the key in such a state, and confirm or rule out the theory above.

In general, registry redirection was a technique that cause several problems with our unit tests and we'd like to remove it from our product.

I hope this helps.
 
To unsubscribe from this group and stop receiving emails from it, send an email to omaha-discuss+unsubscribe@googlegroups.com.

Nhan Nguyen

unread,
Nov 26, 2016, 11:59:39 AM11/26/16
to Omaha Discuss
Problem was caused because of an antivirus/internet security program.
I have doubts about that, so decided to remove that program from computer.
Then it works.

So, the advice for those, who are going to run omaha_unittest, is stoping all antivirus/internet security programs if problems related to delete regkey are raised. 

BTW, thank you for your support, Sorin! 
Reply all
Reply to author
Forward
0 new messages