1. 05 6月, 2018 1 次提交
  2. 29 5月, 2018 16 次提交
    • M
      kconfig: test: add Kconfig macro language tests · 2bece88f
      Masahiro Yamada 提交于
      Here are the test cases I used for developing the text expansion
      feature.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      2bece88f
    • M
      kconfig: error out if a recursive variable references itself · 915f6490
      Masahiro Yamada 提交于
      When using a recursively expanded variable, it is a common mistake
      to make circular reference.
      
      For example, Make terminates the following code:
      
        X = $(X)
        Y := $(X)
      
      Let's detect the circular expansion in Kconfig, too.
      
      On the other hand, a function that recurses itself is a commonly-used
      programming technique.  So, Make does not check recursion in the
      reference with 'call'.  For example, the following code continues
      running eternally:
      
        X = $(call X)
        Y := $(X)
      
      Kconfig allows circular expansion if one or more arguments are given,
      but terminates when the same function is recursively invoked 1000 times,
      assuming it is a programming mistake.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      915f6490
    • M
      kconfig: add 'filename' and 'lineno' built-in variables · a702a617
      Masahiro Yamada 提交于
      The special variables, $(filename) and $(lineno), are expanded to a
      file name and its line number being parsed, respectively.
      Suggested-by: NRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      a702a617
    • M
      kconfig: add 'info', 'warning-if', and 'error-if' built-in functions · 1d6272e6
      Masahiro Yamada 提交于
      Syntax:
        $(info,<text>)
        $(warning-if,<condition>,<text>)
        $(error-if,<condition>,<text)
      
      The 'info' function prints a message to stdout as in Make.
      
      The 'warning-if' and 'error-if' are similar to 'warning' and 'error'
      in Make, but take the condition parameter.  They are effective only
      when the <condition> part is y.
      
      Kconfig does not implement the lazy expansion as used in the 'if'
      'and, 'or' functions in Make.  In other words, Kconfig does not
      support conditional expansion.  The unconditional 'error' function
      would always terminate the parsing, hence would be useless in Kconfig.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      1d6272e6
    • M
      kconfig: expand lefthand side of assignment statement · 82bc8bd8
      Masahiro Yamada 提交于
      Make expands the lefthand side of assignment statements.  In fact,
      Kbuild relies on it since kernel makefiles mostly look like this:
      
        obj-$(CONFIG_FOO) += foo.o
      
      Do likewise in Kconfig.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      82bc8bd8
    • M
      kconfig: support append assignment operator · ed2a22f2
      Masahiro Yamada 提交于
      Support += operator.  This appends a space and the text on the
      righthand side to a variable.
      
      The timing of the evaluation of the righthand side depends on the
      flavor of the variable.  If the lefthand side was originally defined
      as a simple variable, the righthand side is expanded immediately.
      Otherwise, the expansion is deferred.  Appending something to an
      undefined variable results in a recursive variable.
      
      To implement this, we need to remember the flavor of variables.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      ed2a22f2
    • M
      kconfig: support simply expanded variable · 1175c025
      Masahiro Yamada 提交于
      The previous commit added variable and user-defined function.  They
      work similarly in the sense that the evaluation is deferred until
      they are used.
      
      This commit adds another type of variable, simply expanded variable,
      as we see in Make.
      
      The := operator defines a simply expanded variable, expanding the
      righthand side immediately.  This works like traditional programming
      language variables.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      1175c025
    • M
      kconfig: support user-defined function and recursively expanded variable · 9ced3bdd
      Masahiro Yamada 提交于
      Now, we got a basic ability to test compiler capability in Kconfig.
      
      config CC_HAS_STACKPROTECTOR
              def_bool $(shell,($(CC) -Werror -fstack-protector -E -x c /dev/null -o /dev/null 2>/dev/null) && echo y || echo n)
      
      This works, but it is ugly to repeat this long boilerplate.
      
      We want to describe like this:
      
      config CC_HAS_STACKPROTECTOR
              bool
              default $(cc-option,-fstack-protector)
      
      It is straight-forward to add a new function, but I do not like to
      hard-code specialized functions like that.  Hence, here is another
      feature, user-defined function.  This works as a textual shorthand
      with parameterization.
      
      A user-defined function is defined by using the = operator, and can
      be referenced in the same way as built-in functions.  A user-defined
      function in Make is referenced like $(call my-func,arg1,arg2), but I
      omitted the 'call' to make the syntax shorter.
      
      The definition of a user-defined function contains $(1), $(2), etc.
      in its body to reference the parameters.  It is grammatically valid
      to pass more or fewer arguments when calling it.  We already exploit
      this feature in our makefiles; scripts/Kbuild.include defines cc-option
      which takes two arguments at most, but most of the callers pass only
      one argument.
      
      By the way, a variable is supported as a subset of this feature since
      a variable is "a user-defined function with zero argument".  In this
      context, I mean "variable" as recursively expanded variable.  I will
      add a different flavored variable in the next commit.
      
      The code above can be written as follows:
      
      [Example Code]
      
        success = $(shell,($(1)) >/dev/null 2>&1 && echo y || echo n)
        cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
      
        config CC_HAS_STACKPROTECTOR
                def_bool $(cc-option,-fstack-protector)
      
      [Result]
        $ make -s alldefconfig && tail -n 1 .config
        CONFIG_CC_HAS_STACKPROTECTOR=y
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      9ced3bdd
    • M
      kconfig: begin PARAM state only when seeing a command keyword · 9de07153
      Masahiro Yamada 提交于
      Currently, any statement line starts with a keyword with TF_COMMAND
      flag.  So, the following three lines are dead code.
      
              alloc_string(yytext, yyleng);
              zconflval.string = text;
              return T_WORD;
      
      If a T_WORD token is returned in this context, it will cause syntax
      error in the parser anyway.
      
      The next commit will support the assignment statement where a line
      starts with an arbitrary identifier.  So, I want the lexer to switch
      to the PARAM state only when it sees a command keyword.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      9de07153
    • M
      kconfig: add 'shell' built-in function · 2fd5b09c
      Masahiro Yamada 提交于
      This accepts a single command to execute.  It returns the standard
      output from it.
      
      [Example code]
      
        config HELLO
                string
                default "$(shell,echo hello world)"
      
        config Y
                def_bool $(shell,echo y)
      
      [Result]
      
        $ make -s alldefconfig && tail -n 2 .config
        CONFIG_HELLO="hello world"
        CONFIG_Y=y
      
      Caveat:
      Like environments, functions are expanded in the lexer.  You cannot
      pass symbols to function arguments.  This is a limitation to simplify
      the implementation.  I want to avoid the dynamic function evaluation,
      which would introduce much more complexity.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      2fd5b09c
    • M
      kconfig: add built-in function support · e298f3b4
      Masahiro Yamada 提交于
      This commit adds a new concept 'function' to do more text processing
      in Kconfig.
      
      A function call looks like this:
      
        $(function,arg1,arg2,arg3,...)
      
      This commit adds the basic infrastructure to expand functions.
      Change the text expansion helpers to take arguments.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      e298f3b4
    • M
      kconfig: make default prompt of mainmenu less specific · 137c0118
      Masahiro Yamada 提交于
      If "mainmenu" is not specified, "Linux Kernel Configuration" is used
      as a default prompt.
      
      Given that Kconfig is used in other projects than Linux, let's use
      a more generic prompt, "Main menu".
      Suggested-by: NSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      137c0118
    • M
      kconfig: remove sym_expand_string_value() · 5b31a974
      Masahiro Yamada 提交于
      There is no more caller of sym_expand_string_value().
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      5b31a974
    • M
      kconfig: remove string expansion for mainmenu after yyparse() · 96d8e48d
      Masahiro Yamada 提交于
      Now that environments are expanded in the lexer, conf_parse() does
      not need to expand them explicitly.
      
      The hack introduced by commit 0724a7c3 ("kconfig: Don't leak
      main menus during parsing") can go away.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      96d8e48d
    • M
      kconfig: remove string expansion in file_lookup() · bb222cee
      Masahiro Yamada 提交于
      There are two callers of file_lookup(), but there is no more reason
      to expand the given path.
      
      [1] zconf_initscan()
          This is used to open the first Kconfig.  sym_expand_string_value()
          has never been used in a useful way here; before opening the first
          Kconfig file, obviously there is no symbol to expand.  If you use
          expand_string_value() instead, environments in KBUILD_KCONFIG would
          be expanded, but I do not see practical benefits for that.
      
      [2] zconf_nextfile()
          This is used to open the next file from 'source' statement.
          Symbols in the path like "arch/$SRCARCH/Kconfig" needed expanding,
          but it was replaced with the direct environment expansion.  The
          environment has already been expanded before the token is passed
          to the parser.
      
      By the way, file_lookup() was already buggy; it expanded a given path,
      but it used the path before expansion for look-up:
              if (!strcmp(name, file->name)) {
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      bb222cee
    • M
      kconfig: reference environment variables directly and remove 'option env=' · 104daea1
      Masahiro Yamada 提交于
      To get access to environment variables, Kconfig needs to define a
      symbol using "option env=" syntax.  It is tedious to add a symbol entry
      for each environment variable given that we need to define much more
      such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability
      in Kconfig.
      
      Adding '$' for symbol references is grammatically inconsistent.
      Looking at the code, the symbols prefixed with 'S' are expanded by:
       - conf_expand_value()
         This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list'
       - sym_expand_string_value()
         This is used to expand strings in 'source' and 'mainmenu'
      
      All of them are fixed values independent of user configuration.  So,
      they can be changed into the direct expansion instead of symbols.
      
      This change makes the code much cleaner.  The bounce symbols 'SRCARCH',
      'ARCH', 'SUBARCH', 'KERNELVERSION' are gone.
      
      sym_init() hard-coding 'UNAME_RELEASE' is also gone.  'UNAME_RELEASE'
      should be replaced with an environment variable.
      
      ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced
      without '$' prefix.
      
      The new syntax is addicted by Make.  The variable reference needs
      parentheses, like $(FOO), but you can omit them for single-letter
      variables, like $F.  Yet, in Makefiles, people tend to use the
      parenthetical form for consistency / clarification.
      
      At this moment, only the environment variable is supported, but I will
      extend the concept of 'variable' later on.
      
      The variables are expanded in the lexer so we can simplify the token
      handling on the parser side.
      
      For example, the following code works.
      
      [Example code]
      
        config MY_TOOLCHAIN_LIST
                string
                default "My tools: CC=$(CC), AS=$(AS), CPP=$(CPP)"
      
      [Result]
      
        $ make -s alldefconfig && tail -n 1 .config
        CONFIG_MY_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E"
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      104daea1
  3. 28 5月, 2018 4 次提交
  4. 13 4月, 2018 1 次提交
    • D
      kconfig: extend output of 'listnewconfig' · 17baab68
      Don Zickus 提交于
      We at Red Hat/Fedora have generally tried to have a per file breakdown of
      every config option we set.  This makes it easy for us to add new options
      when they are exposed and keep a changelog of why they were set.
      
      A Fedora example is here:
        https://src.fedoraproject.org/cgit/rpms/kernel.git/tree/configs/fedora/generic
      
      Using various merge scripts, we build up a config file and run it through
      'make listnewconfig' and 'make oldnoconfig'.   The idea is to print out new
      config options that haven't been manually set and use the default until
      a patch is posted to set it properly.
      
      To speed things up, it would be nice to make it easier to generate a
      patch to post the default setting.  The output of 'make listnewconfig'
      has two issues that limit us:
      
      - it doesn't provide the default value
      - it doesn't provide the new 'choice' options that get flagged in
        'oldconfig'
      
      This patch extends 'listnewconfig' to address the above two issues.
      
      This allows us to run a script
      
      make listnewconfig | rhconfig-tool -o patches; git send-email patches/
      
      The output of 'make listnewconfig':
      
      CONFIG_NET_EMATCH_IPT
      CONFIG_IPVLAN
      CONFIG_ICE
      CONFIG_NET_VENDOR_NI
      CONFIG_IEEE802154_MCR20A
      CONFIG_IR_IMON_DECODER
      CONFIG_IR_IMON_RAW
      
      The new output of 'make listnewconfig':
      
      CONFIG_KERNEL_XZ=n
      CONFIG_KERNEL_LZO=n
      CONFIG_NET_EMATCH_IPT=n
      CONFIG_IPVLAN=n
      CONFIG_ICE=n
      CONFIG_NET_VENDOR_NI=y
      CONFIG_IEEE802154_MCR20A=n
      CONFIG_IR_IMON_DECODER=n
      CONFIG_IR_IMON_RAW=n
      Signed-off-by: NDon Zickus <dzickus@redhat.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      17baab68
  5. 07 4月, 2018 3 次提交
  6. 26 3月, 2018 15 次提交
    • M
      kconfig: use yylineno option instead of manual lineno increments · 18492685
      Masahiro Yamada 提交于
      Tracking the line number by hand is error-prone since you need to
      increment it in every \n matching pattern.
      
      If '%option yylineno' is set, flex defines 'yylineno' to contain the
      current line number and automatically updates it each time it reads a
      \n character.  This is much more convenient although the lexer does
      not initializes yylineno, so you need to set it to 1 each time you
      start reading a new file, and restore it you go back to the previous
      file.
      
      I tested this with DEBUG_PARSE, and confirmed the same dump message
      was produced.
      
      I removed the perf-report option.  Otherwise, I see the following
      message:
        %option yylineno entails a performance penalty ONLY on rules that
        can match newline characters
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      18492685
    • M
      kconfig: detect recursive inclusion earlier · 379a8eb8
      Masahiro Yamada 提交于
      Currently, the recursive inclusion is not detected when the offending
      file is about to be included; it is detected the offending file is
      about to include the *next* file.  This is because the detection loop
      does not involve the file being included.
      
      Do this check against the file that is about to be included so that
      the recursive inclusion is detected before unneeded parsing happens.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      379a8eb8
    • M
      kconfig: remove duplicated file name and lineno of recursive inclusion · 32a94b8b
      Masahiro Yamada 提交于
      As in the unit test, the error message for the recursive inclusion
      looks like this:
      
        Kconfig.inc1:4: recursive inclusion detected. Inclusion path:
          current file : 'Kconfig.inc1'
          included from: 'Kconfig.inc3:1'
          included from: 'Kconfig.inc2:3'
          included from: 'Kconfig.inc1:4'
      
      The 'Kconfig.inc1:4' is duplicated in the first and last lines.
      Also, the single quotes do not help readability.
      
      Change the message like follows:
      
        Recursive inclusion detected.
        Inclusion path:
          current file : Kconfig.inc1
          included from: Kconfig.inc3:1
          included from: Kconfig.inc2:3
          included from: Kconfig.inc1:4
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      32a94b8b
    • M
      kconfig: do not include both curses.h and ncurses.h for nconfig · 26561514
      Masahiro Yamada 提交于
      nconf.h includes <curses.h> and "ncurses.h", but it does not need to
      include both.  Generally, it should fall back to curses.h only when
      ncurses.h is not found.  But, looks like it has never happened;
      these includes have been here for many years since commit 692d97c3
      ("kconfig: new configuration interface (nconfig)"), and nobody has
      complained about hard-coding of ncurses.h .  Let's simply drop the
      curses.h inclusion.
      
      I replaced "ncurses.h" with <ncurses.h> since it is not a local file.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      26561514
    • M
      kconfig: make unmet dependency warnings readable · f8f69dc0
      Masahiro Yamada 提交于
      Currently, the unmet dependency warnings end up with endlessly long
      expressions, most of which are false positives.
      
      Here is test code to demonstrate how it currently works.
      
      [Test Case]
      
        config DEP1
                def_bool y
      
        config DEP2
                bool "DEP2"
      
        config A
                bool "A"
                select E
      
        config B
                bool "B"
                depends on DEP2
                select E
      
        config C
                bool "C"
                depends on DEP1 && DEP2
                select E
      
        config D
                def_bool n
                select E
      
        config E
                bool
                depends on DEP1 && DEP2
      
      [Result]
      
        $ make config
        scripts/kconfig/conf  --oldaskconfig Kconfig
        *
        * Linux Kernel Configuration
        *
        DEP2 (DEP2) [N/y/?] (NEW) n
        A (A) [N/y/?] (NEW) y
        warning: (A && B && D) selects E which has unmet direct
        dependencies (DEP1 && DEP2)
      
      Here, I see some points to be improved.
      
      First, '(A || B || D)' would make more sense than '(A && B && D)'.
      I am not sure if this is intentional, but expr_simplify_unmet_dep()
      turns OR expressions into AND, like follows:
      
              case E_OR:
                      return expr_alloc_and(
      
      Second, we see false positives.  'A' is a real unmet dependency.
      'B' is false positive because 'DEP1' is fixed to 'y', and 'B' depends
      on 'DEP2'.  'C' was correctly dropped by expr_simplify_unmet_dep().
      'D' is also false positive because it has no chance to be enabled.
      Current expr_simplify_unmet_dep() cannot avoid those false positives.
      
      After all, I decided to use the same helpers as used for printing
      reverse dependencies in the help.
      
      With this commit, unreadable warnings (most of the reported symbols are
      false positives) in the real world:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      warning: (HWSPINLOCK_QCOM && AHCI_MTK && STMMAC_PLATFORM &&
       DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_OXNAS && DWMAC_ROCKCHIP &&
       DWMAC_SOCFPGA && DWMAC_STI && TI_CPSW && PINCTRL_GEMINI &&
       PINCTRL_OXNAS && PINCTRL_ROCKCHIP && PINCTRL_DOVE &&
       PINCTRL_ARMADA_37XX && PINCTRL_STM32 && S3C2410_WATCHDOG &&
       VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 &&
       LPC18XX_DMAMUX && VIDEO_OMAP4 && COMMON_CLK_GEMINI &&
       COMMON_CLK_ASPEED && COMMON_CLK_NXP && COMMON_CLK_OXNAS &&
       COMMON_CLK_BOSTON && QCOM_ADSP_PIL && QCOM_Q6V5_PIL && QCOM_GSBI &&
       ATMEL_EBI && ST_IRQCHIP && RESET_IMX7 && PHY_HI6220_USB &&
       PHY_RALINK_USB && PHY_ROCKCHIP_PCIE && PHY_DA8XX_USB) selects
       MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM)
      warning: (PINCTRL_AT91 && PINCTRL_AT91PIO4 && PINCTRL_OXNAS &&
       PINCTRL_PISTACHIO && PINCTRL_PIC32 && PINCTRL_MESON &&
       PINCTRL_NOMADIK && PINCTRL_MTK && PINCTRL_MT7622 && GPIO_TB10X)
       selects OF_GPIO which has unmet direct dependencies (GPIOLIB && OF &&
       HAS_IOMEM)
      warning: (FAULT_INJECTION_STACKTRACE_FILTER && LATENCYTOP && LOCKDEP)
       selects FRAME_POINTER which has unmet direct dependencies
       (DEBUG_KERNEL && (CRIS || M68K || FRV || UML || SUPERH || BLACKFIN ||
       MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS)
      
      will be turned into:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      
      WARNING: unmet direct dependencies detected for MFD_SYSCON
        Depends on [n]: HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_STM32 [=y] && PINCTRL [=y] && (ARCH_STM32 ||
       COMPILE_TEST [=y]) && OF [=y]
        - RTC_DRV_AT91SAM9 [=y] && RTC_CLASS [=y] && (ARCH_AT91 ||
       COMPILE_TEST [=y])
        - RESET_IMX7 [=y] && RESET_CONTROLLER [=y]
        - PHY_HI6220_USB [=y] && (ARCH_HISI && ARM64 ||
       COMPILE_TEST [=y])
        - PHY_RALINK_USB [=y] && (RALINK || COMPILE_TEST [=y])
        - PHY_ROCKCHIP_PCIE [=y] && (ARCH_ROCKCHIP && OF [=y] ||
       COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for OF_GPIO
        Depends on [n]: GPIOLIB [=y] && OF [=y] && HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_MTK [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y]
        - PINCTRL_MT7622 [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y] && (ARM64 || COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for FRAME_POINTER
        Depends on [n]: DEBUG_KERNEL [=y] && (CRIS || M68K || FRV || UML ||
       SUPERH || BLACKFIN || MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS [=n]
        Selected by [y]:
        - LATENCYTOP [=y] && DEBUG_KERNEL [=y] && STACKTRACE_SUPPORT [=y] &&
       PROC_FS [=y] && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND &&
       !ARC && !X86
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NPetr Vorel <petr.vorel@gmail.com>
      f8f69dc0
    • M
      kconfig: warn unmet direct dependency of tristate symbols selected by y · f622f827
      Masahiro Yamada 提交于
      Commit 246cf9c2 ("kbuild: Warn on selecting symbols with unmet
      direct dependencies") forcibly promoted ->dir_dep.tri to yes from mod.
      So, the unmet direct dependencies of tristate symbols are not reported.
      
      [Test Case]
      
        config MODULES
                def_bool y
                option modules
      
        config A
                def_bool y
                select B
      
        config B
                tristate "B"
                depends on m
      
      This causes unmet dependency because 'B' is forced 'y' ignoring
      'depends on m'.  This should be warned.
      
      On the other hand, the following case ('B' is bool) should not be
      warned, so 'depends on m' for bool symbols should be naturally treated
      as 'depends on y'.
      
      [Test Case2 (not unmet dependency)]
      
        config MODULES
                def_bool y
                option modules
      
        config A
                def_bool y
                select B
      
        config B
                bool "B"
                depends on m
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      f622f827
    • M
      kconfig: tests: test if recursive inclusion is detected · e2c75e76
      Masahiro Yamada 提交于
      If recursive inclusion is detected, it should fail with error
      messages.  Test this.
      
      This also tests the line numbers in the error message, fixed by
      commit 5ae6fcc4 ("kconfig: fix line number in recursive inclusion
      error message").
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      e2c75e76
    • M
      kconfig: tests: test if recursive dependencies are detected · 29c434f3
      Masahiro Yamada 提交于
      Recursive dependency should be detected and warned.  Test this.
      
      This indirectly tests the line number increments.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      29c434f3
    • M
      kconfig: tests: test randconfig for choice in choice · 3e4888c2
      Masahiro Yamada 提交于
      Commit 3b9a19e0 ("kconfig: loop as long as we changed some symbols
      in randconfig") fixed randconfig where a choice contains a sub-choice.
      Prior to that commit, the sub-choice values were not set.
      
      I am not sure whether this is an intended feature or just something
      people discovered works, but it is used in the real world;
      drivers/usb/gadget/legacy/Kconfig is source'd in a choice context,
      then creates a sub-choice in it.
      
      For the test case in this commit, there are 3 possible results.
      
      Case 1:
        CONFIG_A=y
        # CONFIG_B is not set
      
      Case 2:
        # CONFIG_A is not set
        CONFIG_B=y
        CONFIG_C=y
        # CONFIG_D is not set
      
      Case 3:
        # CONFIG_A is not set
        CONFIG_B=y
        # CONFIG_C is not set
        CONFIG_D=y
        CONFIG_E=y
      
      So, this test iterates several times, and checks if the result is
      either of the three.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      3e4888c2
    • M
      kconfig: tests: test defconfig when two choices interact · beaaddb6
      Masahiro Yamada 提交于
      Commit fbe98bb9 ("kconfig: Fix defconfig when one choice menu
      selects options that another choice menu depends on") fixed defconfig
      when two choices interact (i.e. calculating the visibility of a choice
      requires to calculate another choice).
      
      The test code in that commit log was based on the real world example,
      and complicated.  So, I shrunk it down to the following:
      
      defconfig.choice:
      ---8<---
      CONFIG_CHOICE_VAL0=y
      ---8<---
      
      ---8<---
      config MODULES
              def_bool y
              option modules
      
      choice
              prompt "Choice"
      
      config CHOICE_VAL0
              tristate "Choice 0"
      
      config CHOICE_VAL1
              tristate "Choice 1"
      
      endchoice
      
      choice
              prompt "Another choice"
              depends on CHOICE_VAL0
      
      config DUMMY
              bool "dummy"
      
      endchoice
      ---8<---
      
      Prior to commit fbe98bb9,
      
        $ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice
      
      resulted in:
      
        CONFIG_MODULES=y
        CONFIG_CHOICE_VAL0=m
        # CONFIG_CHOICE_VAL1 is not set
        CONFIG_DUMMY=y
      
      where the expected result would be:
      
        CONFIG_MODULES=y
        CONFIG_CHOICE_VAL0=y
        # CONFIG_CHOICE_VAL1 is not set
        CONFIG_DUMMY=y
      
      Roughly, this weird behavior happened like this:
      
      Symbols are calculated a couple of times.  First, all symbols are
      calculated in conf_read().  The first 'choice' is evaluated to 'y'
      due to the SYMBOL_DEF_USER flag, but sym_calc_choice() clears it
      unless all of its choice values are explicitly set by the user.
      
      conf_set_all_new_symbols() clears all SYMBOL_VALID flags.  Then, only
      choices are calculated.  Here, the SYMBOL_DEF_USER for the first choice
      has been forgotten, so it is evaluated to 'm'.  set_all_choice_values()
      sets SYMBOL_DEF_USER again to choice symbols.
      
      When calculating the second choice, due to 'depends on CHOICE_VAL0',
      it triggers the calculation of CHOICE_VAL0.  As a result, SYMBOL_VALID
      is set for CHOICE_VAL0.
      
      Symbols except choices get the final chance of re-calculation in
      conf_write().  In a normal case, CHOICE_VAL0 would be re-calculated,
      then the first choice would be indirectly re-calculated with the
      SYMBOL_DEF_USER which has been recalled by set_all_choice_values(),
      which would be evaluated to 'y'.  But, in this case, CHOICE_VAL0 has
      already been marked as SYMBOL_VALID, so this re-calculation does not
      happen.  Then, =m from the conf_set_all_new_symbols() phase is written
      out to the .config file.
      
      Add a unit test for this naive case.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      beaaddb6
    • M
      kconfig: tests: check visibility of tristate choice values in y choice · ee236610
      Masahiro Yamada 提交于
      If tristate choice values depend on symbols set to 'm', they should be
      hidden when the choice containing them is changed from 'm' to 'y'
      (i.e. exclusive choice).
      
      This issue was fixed by commit fa64e5f6 ("kconfig/symbol.c: handle
      choice_values that depend on 'm' symbols").
      
      Add a test case to avoid regression.
      
      For the input in this unit test, there is a room for argument if
      "# CONFIG_CHOICE1 is not set" should be written to the .config file.
      
      After commit fa64e5f6, this line was written to the .config file.
      
      With commit cb67ab2c ("kconfig: do not write choice values when
      their dependency becomes n"), it is not written now.
      
      In this test, "# CONFIG_CHOICE1 is not set" is don't care.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      ee236610
    • M
      kconfig: tests: check unneeded "is not set" with unmet dependency · 930c429a
      Masahiro Yamada 提交于
      Commit cb67ab2c ("kconfig: do not write choice values when their
      dependency becomes n") fixed a problem where "# CONFIG_... is not set"
      for choice values are wrongly written into the .config file when they
      are once visible, then become invisible later.
      
      Add a test for this naive case.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      930c429a
    • M
      kconfig: tests: test if new symbols in choice are asked · b76960c0
      Masahiro Yamada 提交于
      If new choice values are added with new dependency, and they become
      visible during user configuration, oldconfig should recognize them
      as (NEW), and ask the user for choice.
      
      This issue was fixed by commit 5d09598d ("kconfig: fix new choices
      being skipped upon config update").
      
      This is a subtle corner case.  Add a test case to avoid breakage.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      b76960c0
    • M
      kconfig: tests: test automatic submenu creation · 49ac3c0c
      Masahiro Yamada 提交于
      If a symbols has dependency on the preceding symbol, the menu entry
      should become the submenu of the preceding one, and displayed with
      deeper indentation.
      
      This is done by restructuring the menu tree in menu_finalize().
      It is a bit complicated computation, so let's add a test case.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      49ac3c0c
    • M
      kconfig: tests: add basic choice tests · 1903c511
      Masahiro Yamada 提交于
      The calculation of 'choice' is a bit complicated part in Kconfig.
      
      The behavior of 'y' choice is intuitive.  If choice values are tristate,
      the choice can be 'm' where each value can be enabled independently.
      Also, if a choice is marked as 'optional', the whole choice can be
      invisible.
      
      Test basic functionality of choice.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      1903c511