-
Notifications
You must be signed in to change notification settings - Fork 10
/
errors_test.go
356 lines (288 loc) · 18.1 KB
/
errors_test.go
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
// Copyright 2019 Canonical Ltd.
// Licensed under the LGPLv3 with static-linking exception.
// See LICENCE file for details.
package tpm2_test
import (
"errors"
. "gopkg.in/check.v1"
. "github.com/canonical/go-tpm2"
internal_testutil "github.com/canonical/go-tpm2/internal/testutil"
)
type errorsSuite struct{}
var _ = Suite(&errorsSuite{})
func (s *errorsSuite) TestDecodeSuccess(c *C) {
c.Check(DecodeResponseCode(CommandClear, ResponseSuccess), IsNil)
}
func (s *errorsSuite) TestDecodeBadTag(c *C) {
err := DecodeResponseCode(CommandGetCapability, ResponseBadTag)
c.Check(err, ErrorMatches, "TPM returned a TPM_RC_BAD_TAG error whilst executing command TPM_CC_GetCapability")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMErrorBadTag{})
c.Check(err.(*TPMErrorBadTag), DeepEquals, &TPMErrorBadTag{Command: CommandGetCapability})
c.Check(err.(*TPMErrorBadTag).ResponseCode(), Equals, ResponseBadTag)
}
func (s *errorsSuite) TestDecodeInvalid(c *C) {
err := DecodeResponseCode(CommandGetCapability, 0x1)
c.Check(err, ErrorMatches, "invalid response code 0x00000001")
c.Assert(err, internal_testutil.ConvertibleTo, InvalidResponseCodeError(0))
c.Check(err.(InvalidResponseCodeError), Equals, InvalidResponseCodeError(0x1))
}
func (s *errorsSuite) TestDecodeInvalidParameter(c *C) {
err := DecodeResponseCode(CommandStartAuthSession, 0xc9)
c.Check(err, ErrorMatches, "invalid response code 0x000000c9")
c.Assert(err, internal_testutil.ConvertibleTo, InvalidResponseCodeError(0))
c.Check(err.(InvalidResponseCodeError), Equals, InvalidResponseCodeError(0xc9))
}
func (s *errorsSuite) TestDecodeInvalidSession(c *C) {
err := DecodeResponseCode(CommandUnseal, 0x88e)
c.Check(err, ErrorMatches, "invalid response code 0x0000088e")
c.Assert(err, internal_testutil.ConvertibleTo, InvalidResponseCodeError(0))
c.Check(err.(InvalidResponseCodeError), Equals, InvalidResponseCodeError(0x88e))
}
func (s *errorsSuite) TestDecodeVendorError(c *C) {
rc := ResponseCode(0xa5a5057e)
err := DecodeResponseCode(CommandLoad, rc)
c.Check(err, ErrorMatches, "TPM returned a vendor defined error whilst executing command TPM_CC_Load: 0xa5a5057e")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMVendorError{})
c.Check(err.(*TPMVendorError), DeepEquals, &TPMVendorError{Command: CommandLoad, Code: rc})
}
func (s *errorsSuite) TestDecodeWarning(c *C) {
err := DecodeResponseCode(CommandNVWrite, 0x923)
c.Check(err, ErrorMatches, "TPM returned a warning whilst executing command TPM_CC_NV_Write: TPM_RC_NV_UNAVAILABLE \\(the command may require writing of NV and NV is not current accessible\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMWarning{})
c.Check(err.(*TPMWarning), DeepEquals, &TPMWarning{Command: CommandNVWrite, Code: WarningNVUnavailable})
c.Check(err.(*TPMWarning).ResponseCode(), Equals, ResponseCode(0x923))
}
func (s *errorsSuite) TestDecodeWarningSelfTest(c *C) {
err := DecodeResponseCode(CommandGetRandom, 0x90a)
c.Check(err, ErrorMatches, "TPM returned a warning whilst executing command TPM_CC_GetRandom: TPM_RC_TESTING \\(TPM is performing self-tests\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMWarning{})
c.Check(err.(*TPMWarning), DeepEquals, &TPMWarning{Command: CommandGetRandom, Code: WarningTesting})
c.Check(err.(*TPMWarning).ResponseCode(), Equals, ResponseCode(0x90a))
}
func (s *errorsSuite) TestDecodeAsyncSelfTest(c *C) {
err := DecodeResponseCode(CommandSelfTest, 0x90a)
c.Check(err, IsNil)
}
func (s *errorsSuite) TestDecodeError0(c *C) {
err := DecodeResponseCode(CommandUnseal, 0x128)
c.Check(err, ErrorMatches, "TPM returned an error whilst executing command TPM_CC_Unseal: TPM_RC_PCR_CHANGED \\(PCR have changed since checked\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMError{})
c.Check(err.(*TPMError), DeepEquals, &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged})
c.Check(err.(*TPMError).ResponseCode(), Equals, ResponseCode(0x128))
}
func (s *errorsSuite) TestDecodeError1(c *C) {
err := DecodeResponseCode(CommandGetRandom, 0x9a)
c.Check(err, ErrorMatches, "TPM returned an error whilst executing command TPM_CC_GetRandom: TPM_RC_INSUFFICIENT \\(the TPM was unable to unmarshal a value because there were not enough octets in the input buffer\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMError{})
c.Check(err.(*TPMError), DeepEquals, &TPMError{Command: CommandGetRandom, Code: ErrorInsufficient})
c.Check(err.(*TPMError).ResponseCode(), Equals, ResponseCode(0x9a))
}
func (s *errorsSuite) TestDecodeParameterError(c *C) {
err := DecodeResponseCode(CommandStartAuthSession, 0x4c9)
c.Check(err, ErrorMatches, "TPM returned an error for parameter 4 whilst executing command TPM_CC_StartAuthSession: TPM_RC_MODE \\(mode of operation not supported\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMParameterError{})
c.Check(err.(*TPMParameterError), DeepEquals, &TPMParameterError{TPMError: &TPMError{Command: CommandStartAuthSession, Code: ErrorMode}, Index: 4})
c.Check(err.(*TPMParameterError).ResponseCode(), Equals, ResponseCode(0x4c9))
}
func (s *errorsSuite) TestDecodeSessionError(c *C) {
err := DecodeResponseCode(CommandUnseal, 0x98e)
c.Check(err, ErrorMatches, "TPM returned an error for session 1 whilst executing command TPM_CC_Unseal: TPM_RC_AUTH_FAIL \\(the authorization HMAC check failed and DA counter incremented\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMSessionError{})
c.Check(err.(*TPMSessionError), DeepEquals, &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorAuthFail}, Index: 1})
c.Check(err.(*TPMSessionError).ResponseCode(), Equals, ResponseCode(0x98e))
}
func (s *errorsSuite) TestDecodeHandleError(c *C) {
err := DecodeResponseCode(CommandCertify, 0x29c)
c.Check(err, ErrorMatches, "TPM returned an error for handle 2 whilst executing command TPM_CC_Certify: TPM_RC_KEY \\(key fields are not compatible with the selected use\\)")
c.Assert(err, internal_testutil.ConvertibleTo, &TPMHandleError{})
c.Check(err.(*TPMHandleError), DeepEquals, &TPMHandleError{TPMError: &TPMError{Command: CommandCertify, Code: ErrorKey}, Index: 2})
c.Check(err.(*TPMHandleError).ResponseCode(), Equals, ResponseCode(0x29c))
}
func (s *errorsSuite) TestTPMErrorIs1(c *C) {
err := &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}
c.Check(err.Is(&TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMErrorIs2(c *C) {
err := &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}
c.Check(err.Is(&TPMError{Command: AnyCommandCode, Code: ErrorPCRChanged}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMErrorIs3(c *C) {
err := &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}
c.Check(err.Is(&TPMError{Command: CommandUnseal, Code: AnyErrorCode}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMErrorIs4(c *C) {
err := &TPMError{Command: CommandContextLoad, Code: ErrorAuthContext}
c.Check(err.Is(&TPMError{Command: CommandContextLoad, Code: ErrorAuthContext}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMErrorIs5(c *C) {
err := &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}
c.Check(err.Is(&TPMError{Command: CommandSign, Code: ErrorPCRChanged}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMErrorIs6(c *C) {
err := &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}
c.Check(err.Is(&TPMError{Command: CommandUnseal, Code: ErrorInsufficient}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMErrorIs7(c *C) {
err := &TPMError{Command: CommandUnseal, Code: ErrorPCRChanged}
c.Check(err.Is(errors.New("error")), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMWarningIs1(c *C) {
err := &TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}
c.Check(err.Is(&TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMWarningIs2(c *C) {
err := &TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}
c.Check(err.Is(&TPMWarning{Command: AnyCommandCode, Code: WarningContextGap}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMWarningIs3(c *C) {
err := &TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}
c.Check(err.Is(&TPMWarning{Command: CommandStartAuthSession, Code: AnyWarningCode}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMWarningIs4(c *C) {
err := &TPMWarning{Command: CommandLoad, Code: WarningObjectMemory}
c.Check(err.Is(&TPMWarning{Command: CommandLoad, Code: WarningObjectMemory}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMWarningIs5(c *C) {
err := &TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}
c.Check(err.Is(&TPMWarning{Command: CommandContextLoad, Code: WarningContextGap}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMWarningIs6(c *C) {
err := &TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}
c.Check(err.Is(&TPMWarning{Command: CommandStartAuthSession, Code: WarningSessionMemory}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMWarningIs7(c *C) {
err := &TPMWarning{Command: CommandStartAuthSession, Code: WarningContextGap}
c.Check(err.Is(errors.New("error")), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMParameterErrorIs1(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMParameterErrorIs2(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: AnyCommandCode, Code: ErrorValue}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMParameterErrorIs3(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: AnyErrorCode}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMParameterErrorIs4(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: AnyParameterIndex}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMParameterErrorIs5(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandVerifySignature, Code: ErrorSignature}, Index: 2}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandVerifySignature, Code: ErrorSignature}, Index: 2}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMParameterErrorIs6(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandActivateCredential, Code: ErrorValue}, Index: 1}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMParameterErrorIs7(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorIntegrity}, Index: 1}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMParameterErrorIs8(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 2}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMParameterErrorIs9(c *C) {
err := &TPMParameterError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorValue}, Index: 1}
c.Check(err.Is(&TPMError{Command: CommandLoad, Code: ErrorValue}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMSessionErrorIs1(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMSessionErrorIs2(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: AnyCommandCode, Code: ErrorHandle}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMSessionErrorIs3(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: AnyErrorCode}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMSessionErrorIs4(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: AnySessionIndex}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMSessionErrorIs5(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorAttributes}, Index: 3}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorAttributes}, Index: 3}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestTPMSessionErrorIs6(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandLoad, Code: ErrorHandle}, Index: 1}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMSessionErrorIs7(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorAttributes}, Index: 1}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMSessionErrorIs8(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 3}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestTPMSessionErrorIs9(c *C) {
err := &TPMSessionError{TPMError: &TPMError{Command: CommandUnseal, Code: ErrorHandle}, Index: 1}
c.Check(err.Is(&TPMError{Command: CommandUnseal, Code: ErrorHandle}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestIsTPMHandleError1(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestIsTPMHandleError2(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: AnyCommandCode, Code: ErrorValue}, Index: 2}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestIsTPMHandleError3(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: AnyErrorCode}, Index: 2}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestIsTPMHandleError4(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: AnyHandleIndex}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestIsTPMHandleError5(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVDefineSpace, Code: ErrorHierarchy}, Index: 1}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVDefineSpace, Code: ErrorHierarchy}, Index: 1}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestIsTPMHandleError6(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVRead, Code: ErrorValue}, Index: 2}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestIsTPMHandleError7(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorHandle}, Index: 2}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestIsTPMHandleError8(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 1}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestIsTPMHandleError9(c *C) {
err := &TPMHandleError{TPMError: &TPMError{Command: CommandNVWrite, Code: ErrorValue}, Index: 2}
c.Check(err.Is(&TPMError{Command: CommandNVWrite, Code: ErrorValue}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestResourceUnavailableErrorIs1(c *C) {
err := &ResourceUnavailableError{Handle: 0x81000001}
c.Check(err.Is(&ResourceUnavailableError{Handle: 0x81000001}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestResourceUnavailableErrorIs2(c *C) {
err := &ResourceUnavailableError{Handle: 0x80000000}
c.Check(err.Is(&ResourceUnavailableError{Handle: 0x80000000}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestResourceUnavailableErrorIs3(c *C) {
err := &ResourceUnavailableError{Handle: 0x81000001}
c.Check(err.Is(&ResourceUnavailableError{Handle: AnyHandle}), internal_testutil.IsTrue)
}
func (s *errorsSuite) TestResourceUnavailableErrorIs4(c *C) {
err := &ResourceUnavailableError{Handle: 0x81000001}
c.Check(err.Is(&ResourceUnavailableError{Handle: 0x80000000}), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestResourceUnavailableErrorIs5(c *C) {
err := &ResourceUnavailableError{Handle: 0x81000001}
c.Check(err.Is(errors.New("error")), internal_testutil.IsFalse)
}
func (s *errorsSuite) TestResourceUnavailableErrorUnwrap(c *C) {
err := NewResourceUnavailableError(0x81000001, &TPMHandleError{TPMError: &TPMError{Command: CommandNVReadPublic, Code: ErrorHandle}, Index: 1})
c.Check(err.Unwrap(), DeepEquals, &TPMHandleError{TPMError: &TPMError{Command: CommandNVReadPublic, Code: ErrorHandle}, Index: 1})
}