main.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. *
  3. * Copyright (c) 2021 Project CHIP Authors
  4. * All rights reserved.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #include <platform/CHIPDeviceLayer.h>
  19. #include <lib/core/CHIPError.h>
  20. #include <lib/support/CHIPMem.h>
  21. #include "KeyValueStorageTest.h"
  22. #include <platform/KeyValueStoreManager.h>
  23. #include <iostream>
  24. using namespace chip;
  25. int main(int argc, char * argv[])
  26. {
  27. CHIP_ERROR err = CHIP_NO_ERROR;
  28. err = chip::Platform::MemoryInit();
  29. SuccessOrExit(err);
  30. chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init("/tmp/chip_example_kvs");
  31. printf("=============================================\n");
  32. printf("chip-linux-persitent-storage-example starting\n");
  33. printf("=============================================\n");
  34. while (true)
  35. {
  36. printf("Running Tests:\n");
  37. chip::RunKvsTest();
  38. sleep(60); // Run every minute
  39. }
  40. exit:
  41. if (err != CHIP_NO_ERROR)
  42. {
  43. std::cerr << "Failed to run Linux App: " << ErrorStr(err) << std::endl;
  44. // End the program with non zero error code to indicate a error.
  45. return 1;
  46. }
  47. return 0;
  48. }