Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On Tuesday 26 July 2011 17:33:54 Jacek Caban wrote: > On 07/26/11 17:22, Henri Verbeet wrote: > > No, I disagree with the basic idea that stricter tests are necessarily > > better. The advantage of SUCCEEDED is that it's *less* strict. > > We won't agree on that. I prefer comparison against S_OK(or D3D_OK, which is just S_OK) for the ok() lines and SUCCEEDED/FAILED for figuring out control flow inside the tests. At least until a Windows version or driver returns a success value other than D3D_OK. But either way that's not a strong opinion. I am fine with either way, and I think I've used SUCCEEDED/FAILED myself for ok() statements mostly because Henri has used it and to keep the code consistent. signature.asc Description: This is a digitally signed message part.
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On 07/26/11 17:22, Henri Verbeet wrote: > On 26 July 2011 16:57, Jacek Caban wrote: >> Seriously, I'm not talking about anything like that. We get to choose >> between using two things. SUCCEDEED() has no advantages over testing >> exact values in this context. Testing the exact value has a small, but >> still, advantage. I believe we agree on this. Then if you have a choice, > No, I disagree with the basic idea that stricter tests are necessarily > better. The advantage of SUCCEEDED is that it's *less* strict. We won't agree on that. > That said, the specific issue is insignificant enough that I wouldn't > care about e.g. a new test using "hr == D3D_OK". I just don't think > that changing existing tests from SUCCEEDED to "hr == D3D_OK" is > really an improvement. Well, I didn't say anything about changing existing code and I didn't even try to reject a patch because of that. I was commenting a new code that had to be resent to wine-patches anyway, so I don't know what was the discussion about... Cheers, Jacek
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On 26 July 2011 16:57, Jacek Caban wrote: > Seriously, I'm not talking about anything like that. We get to choose > between using two things. SUCCEDEED() has no advantages over testing > exact values in this context. Testing the exact value has a small, but > still, advantage. I believe we agree on this. Then if you have a choice, No, I disagree with the basic idea that stricter tests are necessarily better. The advantage of SUCCEEDED is that it's *less* strict. That said, the specific issue is insignificant enough that I wouldn't care about e.g. a new test using "hr == D3D_OK". I just don't think that changing existing tests from SUCCEEDED to "hr == D3D_OK" is really an improvement.
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On 07/26/11 16:34, Henri Verbeet wrote: > On 26 July 2011 16:08, Jacek Caban wrote: >> If there is no cost of having tests more strict (like code >> complication), it is a good principle IMO. In this case it's a matter of >> choosing the right way for testing results, so it should be preferable. >> > We're not testing return codes here, so IMO we don't care about them > beyond detecting failures early. As a general principle though, the > point has always been to test behaviour that actual applications > depend on, not finding the most obscure implementation details of > native. Also, it's not unheard of for some of those details to change > between Windows versions. If applications don't care, we don't either. I'm sure apps *do* care about return codes. It's not like we're talking about an obscure failure corner cases. >>> (Not that it matters a lot here anyway, for most of these >>> D3D_OK is the only possible sucessful return value.) >> How can you be sure without tests? >> > Well, aside from disassembling the entire thing for every single > Windows version, you can't, even with tests. Yeah, but with tests I can be much more confident saying so. But first of all, I don't care about all versions and all corner cases, I care about the usual case. And that's something tests will show you easily. > I mean, native D3D could > do something obscure like switching all return codes to S_FALSE after > drawing a green icosahedron, but I think it's somewhat unlikely. Seriously, I'm not talking about anything like that. We get to choose between using two things. SUCCEDEED() has no advantages over testing exact values in this context. Testing the exact value has a small, but still, advantage. I believe we agree on this. Then if you have a choice, you choose the one that is slightly better, even if you don't care about this advantage in this particular case. Cheers, Jacek
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On 26 July 2011 16:08, Jacek Caban wrote: > If there is no cost of having tests more strict (like code > complication), it is a good principle IMO. In this case it's a matter of > choosing the right way for testing results, so it should be preferable. > We're not testing return codes here, so IMO we don't care about them beyond detecting failures early. As a general principle though, the point has always been to test behaviour that actual applications depend on, not finding the most obscure implementation details of native. Also, it's not unheard of for some of those details to change between Windows versions. If applications don't care, we don't either. >> (Not that it matters a lot here anyway, for most of these >> D3D_OK is the only possible sucessful return value.) > > How can you be sure without tests? > Well, aside from disassembling the entire thing for every single Windows version, you can't, even with tests. I mean, native D3D could do something obscure like switching all return codes to S_FALSE after drawing a green icosahedron, but I think it's somewhat unlikely.
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On 07/26/11 13:04, Henri Verbeet wrote: > On 26 July 2011 10:57, Jacek Caban wrote: >> It's better to test for the exact value in tests like hr == S_OK. It >> makes tests stricter. > I don't think that making tests more strict than necessary is a good > principle. If there is no cost of having tests more strict (like code complication), it is a good principle IMO. In this case it's a matter of choosing the right way for testing results, so it should be preferable. > (Not that it matters a lot here anyway, for most of these > D3D_OK is the only possible sucessful return value.) How can you be sure without tests? Cheers, Jacek
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
On 26 July 2011 10:57, Jacek Caban wrote: > It's better to test for the exact value in tests like hr == S_OK. It > makes tests stricter. I don't think that making tests more strict than necessary is a good principle. (Not that it matters a lot here anyway, for most of these D3D_OK is the only possible sucessful return value.)
Re: d3d8/tests: make sure to use return values (LLVM/Clang)
Hi Austin, ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DSurface8_GetDesc(surface, &surface_desc); +ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr); It's better to test for the exact value in tests like hr == S_OK. It makes tests stricter. I know there are already tests checking SUCCEEDED(), but while you are at this, let's get it right. Also, patches should go to wine-patches ;) Jacek
d3d8/tests: make sure to use return values (LLVM/Clang)
-- -Austin diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index 9a4369b..d159a52 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -1050,6 +1050,7 @@ static void test_reset(void) hr = IDirect3DDevice8_GetRenderTarget(device1, &surface); ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DSurface8_GetDesc(surface, &surface_desc); +ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr); ok(surface_desc.Width == modes[i].w, "Back buffer width is %u, expected %u.\n", surface_desc.Width, modes[i].w); ok(surface_desc.Height == modes[i].h, "Back buffer height is %u, expected %u.\n", @@ -1088,6 +1089,7 @@ static void test_reset(void) hr = IDirect3DDevice8_GetRenderTarget(device1, &surface); ok(SUCCEEDED(hr), "GetRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DSurface8_GetDesc(surface, &surface_desc); +ok(SUCCEEDED(hr), "GetDesc failed, hr %#x.\n", hr); ok(surface_desc.Width == 400, "Back buffer width is %u, expected 400.\n", surface_desc.Width); ok(surface_desc.Height == 300, "Back buffer height is %u, expected 300.\n", @@ -2600,15 +2602,18 @@ static void test_depth_stencil_size(void) ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DDevice8_GetRenderTarget(device, &surf); +ok(SUCCEEDED(hr), "IDirect3DDevice8_GetRenderTarget failed, hr %#x.\n", hr); ok(surf == rt, "The render target is %p, expected %p\n", surf, rt); IDirect3DSurface8_Release(surf); hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surf); +ok(SUCCEEDED(hr), "IDirect3DDevice8_GetDepthStencilSurface failed, hr %#x.\n", hr); ok(surf == ds_bigger2, "The depth stencil is %p, expected %p\n", surf, ds_bigger2); IDirect3DSurface8_Release(surf); hr = IDirect3DDevice8_SetRenderTarget(device, NULL, NULL); ok(SUCCEEDED(hr), "IDirect3DDevice8_SetRenderTarget failed, hr %#x.\n", hr); hr = IDirect3DDevice8_GetDepthStencilSurface(device, &surf); +ok(FAILED(hr), "IDirect3DDevice8_GetDepthStencilSurface failed, hr %#x.\n", hr); ok(surf == NULL, "The depth stencil is %p, expected NULL\n", surf); if (surf) IDirect3DSurface8_Release(surf);