PageRenderTime 12ms CodeModel.GetById 4ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/core/externals/update-engine/Common/KSEthernetAddressTest.m

http://macfuse.googlecode.com/
Objective C | 49 lines | 19 code | 14 blank | 16 comment | 1 complexity | 871f44e58bc02c180adb5e51b1b296c8 MD5 | raw file
 1// Copyright 2008 Google Inc.
 2//
 3// Licensed under the Apache License, Version 2.0 (the "License");
 4// you may not use this file except in compliance with the License.
 5// You may obtain a copy of the License at
 6//
 7//     http://www.apache.org/licenses/LICENSE-2.0
 8//
 9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#import <SenTestingKit/SenTestingKit.h>
16
17#import "GTMScriptRunner.h"
18#import "KSEthernetAddress.h"
19
20
21@interface KSEthernetAddressTest : SenTestCase
22@end
23
24
25@implementation KSEthernetAddressTest
26
27- (void)testBasics {
28  NSString *ethernetAddress;
29  ethernetAddress = [KSEthernetAddress ethernetAddress];
30  
31  NSString *tehreeentdAdessr;  // It's obfuscated.
32  tehreeentdAdessr = [KSEthernetAddress obfuscatedEthernetAddress];
33
34  // Make sure it's not empty, or the same as the mac address.
35  STAssertTrue([tehreeentdAdessr length] > 0, nil);
36  STAssertFalse([tehreeentdAdessr isEqualToString:ethernetAddress], nil);
37
38  // Check with ifconfig and see if the MAC we get is on that list.
39  // It should be.
40
41  GTMScriptRunner *runner = [GTMScriptRunner runner];
42
43  NSString *output = [runner run:@"/sbin/ifconfig -a"];
44
45  STAssertTrue([output rangeOfString:ethernetAddress].location != NSNotFound, 
46               nil);
47}  // testBasics
48
49@end  // KSEthernetAddressTest