/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. #import <SenTestingKit/SenTestingKit.h>
  15. #import "GTMScriptRunner.h"
  16. #import "KSEthernetAddress.h"
  17. @interface KSEthernetAddressTest : SenTestCase
  18. @end
  19. @implementation KSEthernetAddressTest
  20. - (void)testBasics {
  21. NSString *ethernetAddress;
  22. ethernetAddress = [KSEthernetAddress ethernetAddress];
  23. NSString *tehreeentdAdessr; // It's obfuscated.
  24. tehreeentdAdessr = [KSEthernetAddress obfuscatedEthernetAddress];
  25. // Make sure it's not empty, or the same as the mac address.
  26. STAssertTrue([tehreeentdAdessr length] > 0, nil);
  27. STAssertFalse([tehreeentdAdessr isEqualToString:ethernetAddress], nil);
  28. // Check with ifconfig and see if the MAC we get is on that list.
  29. // It should be.
  30. GTMScriptRunner *runner = [GTMScriptRunner runner];
  31. NSString *output = [runner run:@"/sbin/ifconfig -a"];
  32. STAssertTrue([output rangeOfString:ethernetAddress].location != NSNotFound,
  33. nil);
  34. } // testBasics
  35. @end // KSEthernetAddressTest