From 4d56e330586922c80397f57ebada1bacf6bcd13c Mon Sep 17 00:00:00 2001 From: Connor Rigby Date: Sat, 6 Jun 2020 18:18:36 -0700 Subject: [PATCH] Add real check_system values --- lib/vintage_net_wifi.ex | 12 +++++++++--- mix.exs | 2 +- mix.lock | 2 +- test/vintage_net_wifi_test.exs | 13 +++++++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/vintage_net_wifi.ex b/lib/vintage_net_wifi.ex index 24790e7..8f0a0da 100644 --- a/lib/vintage_net_wifi.ex +++ b/lib/vintage_net_wifi.ex @@ -3,6 +3,7 @@ defmodule VintageNetWiFi do require Logger + alias VintageNet.Command alias VintageNet.Interface.RawConfig alias VintageNet.IP.{DhcpdConfig, DnsdConfig, IPv4Config} alias VintageNetWiFi.{WPA2, WPASupplicant} @@ -310,9 +311,14 @@ defmodule VintageNetWiFi do end @impl true - def check_system(_opts) do - # TODO - :ok + def check_system(opts) do + with :ok <- Command.verify_program(opts, :bin_wpa_supplicant), + :ok <- Command.verify_program(opts, :bin_udhcpc), + :ok <- Command.verify_program(opts, :bin_udhcpd), + :ok <- Command.verify_program(opts, :bin_dnsd), + :ok <- Command.verify_program(opts, :bin_ip) do + :ok + end end defp wifi_to_supplicant_contents(wifi, control_interface_dir, regulatory_domain) do diff --git a/mix.exs b/mix.exs index 158fdeb..795b645 100644 --- a/mix.exs +++ b/mix.exs @@ -65,7 +65,7 @@ defmodule VintageNetWiFi.MixProject do defp deps do [ - {:vintage_net, "~> 0.8.0"}, + {:vintage_net, github: "nerves-networking/vintage_net", branch: "verify-system"}, {:credo, "~> 1.2", only: :test, runtime: false}, {:dialyxir, "~> 1.0.0", only: [:dev, :test], runtime: false}, {:elixir_make, "~> 0.6", runtime: false}, diff --git a/mix.lock b/mix.lock index 94489a8..e98ddc0 100644 --- a/mix.lock +++ b/mix.lock @@ -21,5 +21,5 @@ "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm", "17ef63abde837ad30680ea7f857dd9e7ced9476cdd7b0394432af4bfc241b960"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.5.0", "8516502659002cec19e244ebd90d312183064be95025a319a6c7e89f4bccd65b", [:rebar3], [], "hexpm", "d48d002e15f5cc105a696cf2f1bbb3fc72b4b770a184d8420c8db20da2674b38"}, - "vintage_net": {:hex, :vintage_net, "0.8.0", "6d8788c3a6cfddb8b98bacd30d1c58edf29ddb61130667496828129577dca790", [:make, :mix], [{:busybox, "~> 0.1.5", [hex: :busybox, repo: "hexpm", optional: true]}, {:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:gen_state_machine, "~> 2.0.0 or ~> 2.1.0", [hex: :gen_state_machine, repo: "hexpm", optional: false]}, {:muontrap, "~> 0.5.1 or ~> 0.6.0", [hex: :muontrap, repo: "hexpm", optional: false]}], "hexpm", "492cdec21b8ee9c2a3bb0dfd6fa12d1f2aadb19875c1bf3f780dc5b899dde9eb"}, + "vintage_net": {:git, "https://github.com/nerves-networking/vintage_net.git", "b4891040cef1d77432a6ba3709440d11f9cec5ab", [branch: "verify-system"]}, } diff --git a/test/vintage_net_wifi_test.exs b/test/vintage_net_wifi_test.exs index 9dca74e..5c6ceb8 100644 --- a/test/vintage_net_wifi_test.exs +++ b/test/vintage_net_wifi_test.exs @@ -1821,4 +1821,17 @@ defmodule VintageNetWiFiTest do assert output == VintageNetWiFi.to_raw_config("wlan0", input, default_opts()) end + + test "check_system" do + result = + VintageNetWiFi.check_system( + bin_wpa_supplicant: "/bin/pwd", + bin_udhcpc: "/bin/pwd", + bin_udhcpd: "/bin/pwd", + bin_dnsd: "/bin/pwd", + bin_ip: "/bin/pwd" + ) + + assert result == :ok + end end